Filtering Tests in Vitest

From the Vitest cheat sheet · Filtering & Tags · verified Nov 2026

Filtering Tests

Narrow a run by file path, test name, project, or what changed

bash
vitest run user               # files whose path contains "user"
vitest run -t "login"         # test names matching a regex
vitest run -t "auth > login"  # suite > test (v5 separator)
vitest run --project unit     # one project (or -p unit)
vitest run --changed          # tests affected by uncommitted changes
vitest run --last-failed      # only last run's failures (5.1+)
⚠️ v5 -t joins names with ' > '; 'math adds' no longer matches
⚡ --changed needs git; --since-last-run works without a repository
💡 --last-failed reads the results cache, so it works across runs
📌 file:line filters need the full relative path, not just a name
filtertestNamePatternchangedlast-failed

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet