feat(generator): use runtime-agnostic test runner in GAPIC package templates - #9394
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the test and system-test scripts across various baseline and template package.json files to execute tests using a centralized runner script (node ../../bin/run-test.cjs) instead of invoking c8 mocha directly. There are no review comments, so I have no feedback to provide.
…mplates Updates the CJS and ESM GAPIC package.json templates (and corresponding generator test baselines) to invoke node ../../bin/run-test.cjs --config ../../.mocharc.cjs instead of c8 mocha directly. This ensures newly generated GAPIC client libraries run unit and system tests through bin/run-test.cjs across both Node.js and Bun runtimes.
c0013df to
49ceeae
Compare
danieljbruce
left a comment
There was a problem hiding this comment.
This looks fine for the sake of getting the bun testing changes in, but we really should try to understand the full impact of removing c8 and we should try to understand the reason it was there in the first place.
We use c8 for test coverage and should still aim to have test coverage; however, keeping it within our test execution causes issues when running on different runtimes. The solution is to remove C8 from individual per-package execution and implement a dedicated CI check for test coverage, allowing for a more runtime-agnostic test configuration. |
Currently, the GAPIC TypeScript generator templates hardcode
c8 mocha build/testas the"test"script in every generatedpackage.json. Whenever libraries are generated or regenerated, their test scripts default back toc8, which forces#!/usr/bin/env nodeand prevents tests from running on the Bun runtime.This PR updates the CommonJS and ESM GAPIC
package.jsontemplates incore/generator/gapic-generator-typescript(along with the generator test baselines) to usenode ../../bin/run-test.cjs build/testinstead. When developers or CI runpnpm teston Node.js,bin/run-test.cjscontinues to runc8 mochawith coverage as usual. When invoked withbun --bun run test, Bun intercepts thenodecall and executesbin/run-test.cjsdirectly inside the Bun runtime.