fix: import vitest APIs explicitly and disable injected globals in server tests (#9049) - #9057
Merged
Merged
Conversation
…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
force-pushed
the
claim/issue-9049
branch
from
September 28, 2026 08:18
03853bf to
b2faa6a
Compare
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
Root cause of
vi is not definedinserver/services/cos.test.js: not Node-version related. The file (and 8 other server suites plusserver/vitest.setup.js) usedvi/afterEach/afterAllwithout importing them, relying onglobals: trueinserver/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/#7367recovered-row test and the#7552rehabilitation test). With the server config the file passes under both Node 24 and Node 26.0.0.import { … } from 'vitest'(9 test files + the shared setup file). Found with an AST scan over every non-client*.test.js/*.test.mjsand setup file (2603 files).globals: falseinserver/vitest.config.jsandserver/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
vitest run server/services/cos.test.jsfrom repo root: 2 failed → 155 passed.cd server && vitest runon the 9 touched suites: 333 passed.globals: false: 2540 files passed; the one failure (videoGen/ref2vaWrapper.test.js, 5swaitFortimeout under load) passes standalone and imports everything explicitly — filed as ref2vaWrapper.test.js: cancellation test times out at 5s under full-suite load (suspected flake) #9055.npm run pregate: passed.Also filed while here: #9056 (malformed repo labels with embedded color hex).
Closes #9049