You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Vitest globals or explicit imports in every test file #288
Do tests use Vitest globals (test, expect, vi ambient, typed through vitest/globals), or does each file import { test, expect, vi } from 'vitest'? The choice sets the tsconfig types, the lint setup and the size of each file's diff.
Explicit imports. Every test file and setup file imports the names it uses from vitest (import { test, expect, vi } from 'vitest'). Vitest's globals option stays off.
Why: it is Vitest's default, needs no types entry in tsconfig.json and no lint globals, and keeps vi and expect out of scope in production source. The cost is one import line in each of the 66 test files, which the conversion rewrites anyway.
test or it: each file keeps the one it already uses. No normalising.
Guard: no extra lint rule. Once Jest's types are gone, an unimported expect or a stray jest. is an undeclared name, and typecheck:baseline fails CI on it.
Effect on the lint ticket: the replacement for react-app/jest no longer has to supply globals. That ticket now only decides whether Vitest lint rules are wanted at all.
Activity
jtklein-agents commentedon Nov 22, 2026
Resolution
Explicit imports. Every test file and setup file imports the names it uses from
vitest(import { test, expect, vi } from 'vitest'). Vitest'sglobalsoption stays off.typesentry intsconfig.jsonand no lint globals, and keepsviandexpectout of scope in production source. The cost is one import line in each of the 66 test files, which the conversion rewrites anyway.testorit: each file keeps the one it already uses. No normalising.expector a strayjest.is an undeclared name, andtypecheck:baselinefails CI on it.react-app/jestno longer has to supply globals. That ticket now only decides whether Vitest lint rules are wanted at all.