fix(payment): fix GooglePay strategy spec crashing under Jest 29 / Node 22#3299
Merged
PavlenkoM merged 1 commit intoJun 25, 2026
Merged
Conversation
PavlenkoM
marked this pull request as draft
June 25, 2026 12:55
PavlenkoM
marked this pull request as ready for review
June 25, 2026 13:01
Contributor
Author
|
cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9a86996. Configure here.
bc-ania
approved these changes
Jun 25, 2026
bc-wpietrzak
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What/Why?
The
google-pay-integrationtest suite was failing onmasterwithJest worker encountered N child process exceptions, exceeding retry limit— unrelated to any feature work.Root cause: the CHECKOUT-10061 toolchain upgrade (TypeScript 4.7→5.8, Jest 29 + Node 22, #3273) made the worker crash on unhandled promise rejections; Jest 26 previously tolerated them.
google-pay-payment-strategy.spec.tshad two distinct problems, the first masking the second:button.click()and never await it. When the handler reports an error viaonErrorand re-throws, the rejection is never handled → it crashes the worker. This was amplified by thebuttonbeing created once inbeforeAlland shared across all tests with nodeinitializein between, so click listeners accumulated and a laterbutton.click()fired an earlier test's throwing handler. (The newer container-mode tests added in feat(payment): PI-5215 [FE][Google Pay] Implement container mode in GooglePayPaymentStrategy #3247 already avoid this by capturing and awaiting the handler.)_completeCheckoutFlowto a no-op in the direct-pay describe, but that method is the only placeLoadingHideis called on the success path — soshould hide loading indicator after completing checkoutcould never pass.This PR fixes the suite with test-only changes — no production code is touched:
buttonper test (beforeAll→beforeEach, removed inafterEach) so click listeners can't accumulate across tests.onError,getNonce), capture the registered click handler andawait expect(...).rejects.toThrow(...)instead of fire-and-forgetbutton.click()— matching the existing feat(payment): PI-5215 [FE][Google Pay] Implement container mode in GooglePayPaymentStrategy #3247 container-test pattern.should hide loading indicator after completing checkout, restore the real_completeCheckoutFlow(jsdom only logs the unimplementedwindow.location.replace, it doesn't throw) so the test asserts genuine production behaviour rather than a stub.Rollout/Rollback
No production impact — changes are limited to
packages/google-pay-integration/src/google-pay-payment-strategy.spec.ts. No experiments, feature flags, or database migrations. Rollback is a straight revert of this commit.Testing
npx nx run google-pay-integration:test→ 71 suites / 414 tests pass, run repeatedly with no flaky worker crashes (the failure was timing-sensitive).npx eslint packages/google-pay-integration/src/google-pay-payment-strategy.spec.ts→ clean.onErrortobutton.click()still crashes; the_completeCheckoutFlowtest now exercises the real method (confirmed it callsLoadingHidevia production code, not a stub).Before:

After:

Note
Low Risk
Changes are confined to one spec file with no production code, payment runtime, or deployment impact.
Overview
Test-only updates to
google-pay-payment-strategy.spec.tsso the suite stops crashing Jest workers after the Jest 29 / Node 22 upgrade (unhandled promise rejections are no longer tolerated).Wallet button setup now uses
beforeEachto create and append a fresh DOM node andafterEachto remove it, instead of a sharedbeforeAllbutton that let click listeners stack across tests.For flows that reject (
onErroron widget failure, coupons path whengetNoncefails), tests no longer firebutton.click()without awaiting; they pull the registeredclickhandler fromaddEventListenermocks andawait expect(...).rejects.toThrow(...), matching the existing container-button pattern.In the direct-pay-on-click block,
should hide loading indicator after completing checkoutrestores the real_completeCheckoutFlow(drops the no-op spy) soLoadingHideis asserted on the actual success path instead of a stub that never hid loading.Reviewed by Cursor Bugbot for commit 9a86996. Bugbot is set up for automated code reviews on this repo. Configure here.