Skip to content

Vitest globals or explicit imports in every test file #288

Closed

Description

@jtklein-agents

Question

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.

Activity

  1. added
    wayfinder:grilling
    on Nov 22, 2026
  2. jtklein-agents commented on Nov 22, 2026

    @jtklein-agents
    OwnerAuthor

    Resolution

    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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

wayfinder:grilling

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions