Repository navigation
test: remove --proxyquire-shim from bigtable, spanner, and storage - #9645
danieljbruce wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the external proxyquire dependency with a custom local implementation across the bigtable, spanner, and storage packages, updating test scripts and import paths accordingly. The feedback highlights an issue in the custom proxyquire implementation where directly mutating the user-provided stub object by copying properties from the real module can lead to test pollution or throw a TypeError if the stub is frozen. It is recommended to use a Proxy to dynamically delegate property accesses to the real module instead.
|
This seems to just create a localized shim which is better and acceptable, but adjustments to the exact tests would likely be ideal. |
1 similar comment
|
This seems to just create a localized shim which is better and acceptable, but adjustments to the exact tests would likely be ideal. |
…properties in proxyquire helper
…n proxyquire helper
…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.
8af69b6 to
01e56cd
Compare
…ove-proxyquire-shim-bigtable-spanner-storage
…oogle-test-utils (Path 1B)
…ove-proxyquire-shim-bigtable-spanner-storage
Description
Replaces the global
--proxyquire-shiminhandwritten/bigtable,handwritten/spanner, andhandwritten/storageusing the centralizedproxyquirehelper fromgoogle-test-utils(Path 1B).Impact
Removes
--proxyquire-shimfrombigtable,spanner, andstorageunit test scripts without duplicating per-packagetest/proxyquire.tshelpers.Changes
handwritten/bigtable,handwritten/spanner,handwritten/storage: Import{proxyquire}from'google-test-utils', remove per-packagetest/proxyquire.tshelpers, and remove--proxyquire-shimfrompackage.jsontest scripts.handwritten/bigtable/test/base64keymap.ts: Remove unusedproxyquireimport.handwritten/spanner/observability-test/helper.ts&spanner.ts: Callcontext.disable()insetGlobalContextManagerand re-register the active context manager inEndToEndbeforeEachso OpenTelemetry context propagation remains isolated across test suites.Testing
pnpm testunder both Node.js and Bun (JS_RUNTIME=bun) inhandwritten/bigtable,handwritten/spanner, andhandwritten/storage.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.