Skip to content

fix: import vitest APIs explicitly and disable injected globals in server tests (#9049) - #9057

Merged
atomantic merged 1 commit into
mainfrom
claim/issue-9049
Sep 28, 2026
Merged

atomantic merged 1 commit into
mainfrom
claim/issue-9049

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

Root cause of vi is not defined in server/services/cos.test.js: not Node-version related. The file (and 8 other server suites plus server/vitest.setup.js) used vi / afterEach / afterAll without importing them, relying on globals: true in server/vitest.config.js. When vitest runs a server file from the repo root (vitest run server/services/cos.test.js), no config is loaded, globals are off, and those names are undefined — exactly the 2 failures reported (the #7300/#7367 recovered-row test and the #7552 rehabilitation test). With the server config the file passes under both Node 24 and Node 26.0.0.

  • Add the missing names to each file's existing import { … } from 'vitest' (9 test files + the shared setup file). Found with an AST scan over every non-client *.test.js/*.test.mjs and setup file (2603 files).
  • Set globals: false in server/vitest.config.js and server/vitest.config.db.js, so a missing import now fails in every run rather than only outside the server config — the recurrence guard. Every other suite already imported explicitly.

Test plan

Also filed while here: #9056 (malformed repo labels with embedded color hex).

Closes #9049

…rver tests (#9049)

Nine server suites and the shared setup file used vi/afterEach/afterAll without
importing them, relying on server/vitest.config.js globals:true. Running a file
from the repo root (vitest run server/services/cos.test.js) loads no config, so
those names were undefined and cos.test.js failed with 'vi is not defined'. Not
Node-version related: it passes under Node 24 and 26 with the server config.

Every suite now imports what it uses, and globals is off so a missing import
fails in every run instead of only outside the server config.
@atomantic
atomantic merged commit 46e9490 into main Sep 28, 2026
14 checks passed
@atomantic
atomantic deleted the claim/issue-9049 branch September 28, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

server/services/cos.test.js: 'vi is not defined' despite vitest globals:true (Node 26)

1 participant