Repository navigation
test: wait for the confetti import before each run-page test ends - #105
Merged
Merged
Conversation
A confirmed toggle on the run page starts import('@/lib/confetti') without
awaiting it. When that import was still loading as the next test started its
own, vitest gave the second import the real module, and canvas-confetti threw
on jsdom's null canvas context after every test had passed. Each test now
waits for pending dynamic imports before it ends.
Implements CHECKMATE-09.1 · slice 0 follow-up
Refs #53
|
Sorry @keyurgolani, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 6 days and 5 hours by commenting |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes an intermittent run-page test failure by waiting for fire-and-forget confetti imports to settle during afterEach, preventing Vitest from resolving a concurrent import to the real canvas-confetti module in jsdom; no product code changes are made. Sequence diagram for settling confetti imports between run-page testssequenceDiagram
participant Test as Run-page test
participant Cleanup as afterEach
participant Vitest
participant Confetti as lib/confetti
participant Canvas as jsdom canvas
Test->>Confetti: import('@/lib/confetti')
Test-->>Cleanup: test completes
Cleanup->>Vitest: dynamicImportSettled()
Vitest-->>Cleanup: pending imports settled
Cleanup->>Cleanup: cleanup()
Cleanup->>Vitest: restore mocks and globals
Cleanup-->>Test: next test starts safely
Confetti->>Canvas: canvas-confetti uses mocked module
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Implements CHECKMATE-09.1 · slice 0 (follow-up)
Refs #53
What changed
The run-page test waits for pending dynamic imports at the start of its
afterEach(await vi.dynamicImportSettled()). No product change.Why
A confirmed toggle starts
import('@/lib/confetti')without awaiting it (checklist-detail-client.tsx#L273-L277), and under load the third test's import was still loading when the fourth test started its own. When one file has two imports of the samevi.mocked module pending at once, vitest gives the second one the real module (moduleMocker.ts#L468-L487), so the real canvas-confetti ran and threw on jsdom's null canvas context after all four tests had passed.Verification
Both batches ran six copies of the file in parallel loops, with
npm run test:backendlooping beside them and 18 busy-loop threads, on a shared 18-core machine already near load average 55. Load average ran 59 to 96.clearRectTypeError.With a throwaway patch that delays vitest's fetch of that module by 300 ms and holds the last test open for a second, 3 of 3 runs failed before the change and 0 of 3 after.
Gate:
npx eslinton the changed file exits 0, with noeslint-disableadded.npm run lintreports 37 errors and 48 warnings, same asorigin/next.npx tsc --noEmitreports 0 errors, same asorigin/next.npm testpasses, 43 files and 798 tests.npm run buildpasses with both PocketBase URLs athttp://127.0.0.1:9.Decisions and owner steps
Only the run page fires confetti (
grep -rn "lib/confetti" src), so no other test needed the wait. The wait alone held, socanvas-confettiisn't mocked as well. No owner steps.Summary by Sourcery
Ensure run-page tests wait for pending dynamic imports before completing each test.
Bug Fixes:
Tests: