Vitest "No test files found, exiting with code 1" in CI
Vitest scanned for tests and found none matching its include pattern, so it exits non-zero. Usually the glob does not match your filenames, or CI runs from a directory where no tests live.
What this error means
Vitest prints "No test files found, exiting with code 1" and fails the job. Locally you may run one file by name and see it pass, masking that the default glob matches nothing.
vitest
No test files found, exiting with code 1
include: **/*.{test,spec}.?(c|m)[jt]s?(x)
exclude: **/node_modules/**Common causes
Filenames do not match the include glob
Vitest picks up *.test.*/*.spec.* by default. Files named *.tests.ts or under a non-default folder are ignored.
Wrong working directory or root in CI
If the job runs vitest from the repo root but tests live in a workspace package, the resolved root contains no matching files.
How to fix it
Set an include pattern that matches your files
vitest.config.ts
// vitest.config.ts
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: { include: ['src/**/*.{test,spec}.{ts,tsx}'] },
});Run from the right directory
- Confirm CI runs Vitest in the package that holds the tests (
--rootor aworking-directory). - For monorepos, define a Vitest workspace so each package is discovered.
- Pass
--diror an explicit path to scope discovery if needed.
How to prevent it
- Commit an explicit
includeglob instead of relying on defaults. - Use a Vitest workspace config in monorepos.
- Add a smoke test so an empty run is obviously wrong.
Related guides
Vitest "Failed to resolve import" - Fix Module Resolution in CIFix Vitest "Failed to resolve import 'X' from 'Y'. Does the file exist?" in CI - a missing dependency, an unc…
Vitest "failed to access its internal state" - Duplicate InstallFix Vitest "Vitest failed to access its internal state" in CI - two copies of Vitest loaded at once, a versio…
Jest "Your test suite must contain at least one test"Fix Jest "Your test suite must contain at least one test" in CI - an empty file matched by testMatch, all tes…