Overview
Every CI run of a Vitest suite starts from zero and runs every test, even when a change only touches a few files. The @useblacksmith/vitest plugin uses dependency tracking to run only the tests affected since the last successful run. It is one plugin invitest.config.ts, with no workflow change.
The plugin is in early beta. Options and the cache format may change between releases.
How it works
Each run records the modules and files every test depends on, throughimport, require, and fs. The next run compares the checkout against that record and runs only the tests that reach a changed file. A test the last successful run did not cover always runs.
On Blacksmith runners, Blacksmith transparently stores this record from run to run, with no extra workflow steps. Jobs that run the same suite share one record, so a test that passed in one job is skipped in another.
Install the plugin
The plugin requires Vitest 4.1.1 or newer.vitest run now runs the affected tests.
Vite+
Vite+ runs Vitest undervp test, so the plugin is loaded from the shared vite.config.ts. It requires vite-plus 1.5.0 or newer, the first release that ships Vitest 5.1.
Running locally
The same selection applies locally: a run reruns what changed on disk since the last successful run, committed or not. To run every test locally and select only in CI:Options
Limitations
Files read byglobalSetup, by programs other than Node, or reached over the network are not tracked; declare them with the dependencies option.
A package changed in place at the same version, such as with patch-package or a git dependency, is not seen as changed.
A run with coverage runs every test.
Verify the selection
The plugin logs every decision with a[blacksmith] prefix in the job output: which records were restored, how many test files are affected, and why each one runs. The first run on a repository has no record and runs everything; compare the test step’s duration across later runs.
A run after a change to one source file restores the record, runs only the test file that depends on it, and saves a new record:
No changed files found, exiting with code 0 and the step passes.