Repository navigation
test: remove --proxyquire-shim from logging and pubsub packages - #9644
danieljbruce wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the global proxyquire dependency with a custom local proxyquire.ts implementation across multiple packages (logging-bunyan, logging-winston, logging, and pubsub), updating the corresponding test scripts and imports. Feedback on the changes highlights two main areas of improvement: first, in the new proxyquire.ts files, wrapping individual property assignments in a try...catch block inside the loop would prevent the entire copy process from aborting if a single property assignment fails; second, across several test files, replacing the .then(noop, ...) promise rejection pattern with assert.rejects would make the tests more robust and prevent silent passes on unexpected promise resolutions.
|
This seems to just create a localized shim which is better and acceptable, but adjustments to the exact tests would likely be ideal. |
…translate (#9642) ## Description Replaces proxyquire with sinon and direct stubs across four packages. ## Impact Removes --proxyquire-shim from gax, googleapis-common, error-reporting, and translate unit tests. ## Changes - **Part 1 of 5 in stacked PR series**: **#9642** -> #9643 -> #9644 -> #9645 -> #9646 (b/570680750). - `core/packages/gax`: Replace `proxyquire` in `test/unit/grpc.ts` with `sinon.stub(fs, 'existsSync')` and remove `--proxyquire-shim` from `package.json`. - `core/packages/nodejs-googleapis-common`: Replace `proxyquire` in `test/test.authplus.ts` and `test/test.http2.ts` with `sinon.stub(auth.GoogleAuth.prototype, 'getClient')` and `sinon.stub(coreHttp2, 'connect')`, and remove `--proxyquire-shim` from `package.json`. - `handwritten/error-reporting`: Stub `util.makeAuthenticatedRequestFactory` and `RequestHandler.prototype.request` directly in `test/unit/google-apis/auth-client.ts` and remove `--proxyquire-shim` from `package.json`. - `packages/google-cloud-translate`: Intercept `Module.prototype.require` directly in `test/index.ts` `before()` hook and remove `--proxyquire-shim` from `package.json`. ## Testing - Executed `pnpm test` under both Node.js and Bun (`JS_RUNTIME=bun`) in `core/packages/gax`, `core/packages/nodejs-googleapis-common`, `handwritten/error-reporting`, and `packages/google-cloud-translate`. - Verified strict lint and type checks pass via `bin/linter.mjs --strict`. ## Alternatives - Not merging this pull request was considered, which would leave these four packages dependent on the global `bin/proxyquire-bun-shim.cjs` preload shim.
…properties in proxyquire helper
…se rejection assertions
0e7ca7c to
3ab8240
Compare
…ove-proxyquire-shim-logging-pubsub
…ove-proxyquire-shim-logging-pubsub
Description
Replaces the global
--proxyquire-shiminhandwritten/logging,handwritten/logging-bunyan,handwritten/logging-winston, andhandwritten/pubsubusing the centralizedproxyquirehelper fromgoogle-test-utils(Path 1B).Impact
Removes
--proxyquire-shimfromlogging,logging-bunyan,logging-winston, andpubsubtest scripts without duplicating per-packagetest/proxyquire.tshelpers.Changes
handwritten/logging,handwritten/logging-bunyan,handwritten/logging-winston,handwritten/pubsub: Import{proxyquire}from'google-test-utils', remove per-packagetest/proxyquire.tshelpers, and remove--proxyquire-shimfrompackage.jsontest scripts.Testing
pnpm testunder both Node.js and Bun (JS_RUNTIME=bun) inhandwritten/logging,handwritten/logging-bunyan,handwritten/logging-winston, andhandwritten/pubsub.bin/linter.mjs --strict.Alternatives
test/proxyquire.tsfiles (Path 1A) were replaced with the centralizedgoogle-test-utilshelper (Path 1B) per review discussion in b/570091189.