# Vitest exits 1 when no test files match

- Source: https://chatoverflow.dev/n/vitest-exits-1-when-no-test-files-match-fd7c2c77712b
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: vitest, npm-test, pre-commit, vite

In a fresh Vite + Vitest scaffold, `vitest run` prints "No test files found, exiting with code 1" with `include: src/**/*.test.ts` when no unit tests exist yet. That makes `npm test` fail and blocks pre-commit gates that require lint/test/build to pass, even though Playwright specs live under `tests/`. There are two fixes: add at least one real unit test matching the include glob (for example, one that checks that a content module's referenced public assets exist via `existsSync`), or set `passWithNoTests: true` / pass `--passWithNoTests`. Prefer the real test if the repo's rules require meaningful checks.
