Uh oh!
There was an error while loading. Please reload this page.
improvement(tests): make vitest suites state-safe with auto-unstub of env/global stubs - #5853
Conversation
… env/global stubs - add unstubEnvs/unstubGlobals to vitest config so vi.stubEnv/vi.stubGlobal are restored after every test - move module-scope fetch/crypto/window stubs into beforeEach across executor, data-drains, and knowledge suites so they hold under auto-unstub (several suites were silently hitting live Datadog/BigQuery/Snowflake/OpenAI/Anthropic endpoints when their module-scope stubs were cleared) - converge billing/workspaces/tools/hooks suites onto the shared @sim/testing mock instances and namespace spies instead of rival file-local vi.mock factories, with explicit beforeEach setup and afterAll restore - give lib/core suites private module instances via vite query-suffix imports where module-level state bakes env at import time - stub auth-client/NEXT_PUBLIC_APP_URL in suites that crashed at collection without a local .env Groundwork for eventually running the suite with isolate: false; no CI behavior change (isolation stays on).
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Suites that relied on module-scope Mock wiring shifts away from rival per-file Collection/runtime guards add Reviewed by Cursor Bugbot for commit 11085e0. Configure here. |
Greptile SummaryThis PR makes the Sim Vitest suites safer around shared state. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix(tests): run knowledge utils cases se..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- restoreGlobalDb now mockReset()s entries whose original implementation was undefined instead of leaving the chain-mock delegation installed - add selectDistinctOn to the setup-level createMockDb and to the dashboard suite's delegated key set so the distinct-on path routes under either binding
waleedlatif1
commented
Jul 22, 2026
waleedlatif1
commented
Jul 22, 2026
@cursor review |
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Jul 22, 2026
waleedlatif1
commented
Jul 22, 2026
@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 11085e0. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
Summary
unstubEnvs: true/unstubGlobals: trueto the sim vitest config so env/global stubs are auto-restored after every testfetch/crypto/windowstubs intobeforeEachacross executor, data-drains, and knowledge suites — several suites were silently making live network calls (observed real 401s from Datadog/BigQuery/Snowflake/OpenAI/Anthropic) when their module-scope stubs got cleared@sim/testingmock instances and namespace spies instead of rival file-localvi.mockfactories, with explicitbeforeEachsetup andafterAllrestoreauth-client/NEXT_PUBLIC_APP_URLin suites that crashed at collection without a local.envisolate: falseflip (2.2x faster suite, blocked today by cross-file mock-binding conflicts)Type of Change
Testing
Full
apps/simsuite green locally under current isolated mode (1055/1056; sole failure is a pre-existing local-env ripgrep dependency that passes in CI). Also validated each fixed file standalone and in shared-worker orderings.Checklist