Vitest is the natural testing framework for Vite projects. Its vocabulary for mocking, spying, snapshots, and coverage mirrors Jest but with Vite-native integration — these terms are essential for discussing test strategy.
0 / 5 completed
1 / 5
A developer says: 'Use Vitest instead of Jest — it's faster because it uses Vite's transform pipeline.' What does this mean?
Vitest is a testing framework built on Vite's infrastructure. If your project already uses Vite, Vitest reuses the same TypeScript/JSX transform pipeline — no separate Babel or ts-jest configuration. This means tests use the same module resolution and transforms as production code. In discussions: 'add Vitest' for a Vite project means minimal setup overhead compared to configuring Jest from scratch.
2 / 5
A developer says: 'Use vi.mock() to mock the module, then vi.spyOn() to spy on a specific method.' What is the difference?
vi.mock('module') replaces the entire module — all exports become mock functions. vi.spyOn(object, 'method') replaces a single method on an existing object while leaving others intact, and can verify calls without changing behaviour (unless you add .mockReturnValue()). In discussions: 'spy on it instead of mocking the whole module' means observe the call without replacing the implementation.
3 / 5
A PR review says: 'Use describe() blocks to group related tests.' What is the purpose of describe in test structure?
describe('UserService', () => { test('creates user', ...) })groups related tests under a named scope. Benefits: (1) output is indented under the describe name for readability, (2) beforeEach/afterEach inside a describe only apply to tests in that block, (3) test runners can filter by describe block name. In discussions: 'add a describe block' means organise tests around the unit being tested.
4 / 5
A developer says: 'The test uses a snapshot to verify the component output hasn't changed unexpectedly.' What is snapshot testing?
Snapshot testing serialises component output (rendered HTML, JSON, etc.) and stores it in a __snapshots__ file. On subsequent runs, Vitest compares the output to the stored snapshot — if they differ, the test fails. This catches unintentional regressions. When intentional changes occur, you update the snapshot with --update-snapshots. In reviews: 'update the snapshot' means the change was intentional — update the baseline.
5 / 5
A developer says: 'Use coverage: { reporter: ['lcov'] } to generate a coverage report.' What is test coverage?
Test coverage measures how much of your source code is executed by the test suite. It's reported as percentages: line coverage (which lines ran), branch coverage (which if/else branches were taken), function coverage. An lcov report can be visualised in tools like Codecov or SonarQube. In discussions: 'improve coverage' means write more tests targeting untested branches. '100% coverage' doesn't guarantee correct behaviour — just that every line ran.