Vitest Setup
Register shared Vitest hooks so test isolation behavior stays synchronized across projects.
Summary
- Suppresses
consolecalls and writes toprocess.stdoutandprocess.stderrduring each test. - Clears
process.exitCodebefore each test and restores every Vitest mock afterward. - Receives the consumer's active Vitest functions so hooks bind to the runtime driving the suite.
Why Use This Battery?
- Centralizes the shared setup policy so behavior changes propagate without copying hook bodies between projects.
- Uses the suite's active Vitest runtime so linked packages and monorepos don't register hooks against a different instance.
- Leaves the local setup file available for project-specific hooks without forking the shared baseline.
Usage
Settings
| Setting | Type | Default | Description |
|---|---|---|---|
afterEach | Vitest afterEach | Required | Registers shared cleanup after every test. |
beforeEach | Vitest beforeEach | Required | Registers shared isolation before every test. |
vi | Vitest vi | Required | Creates and restores spies in the active runtime. |