Repository navigation
Conversation
bun restores a spied method when its test file ends but keeps the spy's call history, so a later file's spyOn() on the same method starts with calls it never made. Under some file orders this failed supabaseAuth.test.ts after vortexAdminAuth.test.ts. The invariant test keeps every spying file restoring its spies.
✅ Deploy Preview for vortexfi canceled.
|
✅ Deploy Preview for vrtx-dashboard canceled.
|
✅ Deploy Preview for vortex-sandbox ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Summary
supabaseAuth.test.ts> "continues anonymously only when optional auth receives no credential" fails when it runs aftervortexAdminAuth.test.ts. It passes on its own and under CI's file order. I found it while running the full API suite in the OSS Scanner image (#1430).Root cause: bun restores a spied method when its test file ends, but keeps the spy's call history. A later file's
spyOn()on the same method starts with the earlier file's calls. Here the victim's freshverifyTokenspy already held two["whatever"]calls fromvortexAdminAuth.test.ts.Fix: the three API test files that call
spyOn()but never restore now callmock.restore()in their existingafterEach, like every other spying test file:vortexAdminAuth.test.tsadmin-console.route.test.tsimpersonation.service.test.tsAll their spies are installed inside individual tests, so restoring after each test changes nothing within those files.
Guard:
src/tests/spy-restore.invariants.test.tsfails if any API test file callsspyOn()withoutmock.restore()or.mockRestore(). A runtime reproducer would depend on bun's file order, so the guard checks the rule directly.Verification
All runs in the OSS Scanner image, offline:
vortexAdminAuth.test.ts+supabaseAuth.test.tsgives 1 fail.supabaseAuth.test.tspasses.tsc --noEmitpasses forapps/api.