CodeVetter · Repo Unpack · Extension points
vitest-dev/vitest
Extension contracts span Vite plugins, runners, worker factories, environments, coverage providers, reporters, and browser commands. Most are configuration-selected and resolved before or during execution. Coordinator and worker hooks occupy different runtime boundaries, so extensions must preserve serialization and lifecycle rules. Snapshot customization additionally separates matching from storage.
- configureVitest receives project, vitest, injectTestProjects, and defineCacheKeyGenerator; it runs before reporter initialization, and resolved configuration mutations are not automatically re-resolved.
- config.runner selects a default-exported runner constructor; resolveTestRunner requires importFile, injects moduleRunner, loads serializers/diff options, and wraps callbacks to preserve Vitest RPC reporting.
- Custom worker execution plugs into project.config.poolRunner through a matching name and createPoolWorker(options), after built-in worker choices are exhausted.
- Custom environments resolve from a path or vitest-environment-{name}; loading branches between native and Vite module runners and validates the default export and supplied transformMode.
- Coverage extension modules supply getProvider and optional start/take/stopCoverage hooks; customProviderModule loads through the supplied loader and must provide a default export.
- Browser commands extend a built-in registry through config.browser.commands with identifier validation; triggerCommand prefers project commands, then parent commands, and rejects unsupported names.
- ReportersMap is the built-in output registry, while config.sequence.sequencer supplies shard and sort behavior before execution grouping; these are separate presentation and scheduling extension boundaries.
- Snapshot customization includes composable matcher helpers and storage environments; SnapshotState.create can consume readSnapshotFileData directly instead of evaluating text, and NodeSnapshotEnvironment accepts a custom snapshot-directory name.