Your test suite must contain at least one test
Fixes Jest's 'test suite must contain at least one test' by adding a test, unskipping the suite, or excluding helper files from collection. Use when this exact error names a file. Not for testMatch globs that match nothing at all.
TL;DR
Jest found a test file with zero tests in it. Either the file has no test or it blocks (add one, or stop matching it with testMatch), every suite is skipped with describe.skip (unskip one, or delete the file), or it is a helper file that should never have been collected. In CI, --passWithNoTests turns the hard error into a pass.
Error
FAIL ./tests/helpers.test.ts
Your test suite must contain at least one test.Steps
- Open the named file and check for
test(orit(blocks. Expected: you confirm whether the file defines any tests at all. - If it is a helper (shared fixtures, utilities), exclude it: add it to
testPathIgnorePatternsin jest config, or rename it so it no longer matchestestMatch. Expected: Jest stops collecting the file. - If every suite uses
describe.skip, unskip at least one suite, or delete the file if it is dead code. Expected: the file registers one or more tests. - If the empty suite is expected in some environments (conditionally generated tests), run CI with
--passWithNoTests. Expected: exit code 0 instead of 1 for that job. - Re-run the single file:
npx jest path/to/file. Expected: it passes or fails on real assertions, not the empty-suite error.
When to use
- The exact "Your test suite must contain at least one test" failure names a file.
- A helper or fixture file accidentally matches your test glob.
- An entire suite is skipped and CI treats the empty file as a failure.
When not to use
- The file has tests but they are not found (check
testMatchandrootsinstead). - You want zero-test files to fail loudly; keep the default and fix the files.
- The error appears for every file (your
testMatchprobably matches nothing; different problem).
Tool compatibility
- Jest 27 through 30.
--passWithNoTestsCLI flag, orpassWithNoTests: truein config.testPathIgnorePatternsandtestMatchin jest config.
Variant phrasings
jest test suite must contain at least one test
Same error. The file Jest collected registered zero tests.
jest empty test file error
Usually a helper file matching the test glob, or a fully skipped describe block.
Why it happens
Jest treats a collected file with no tests as a probable misconfiguration (wrong glob, or a broken import that swallowed the test definitions) and fails it rather than silently passing. Skipped suites register zero tests, so a fully describe.skipped file trips the same error.
Edge cases
- A file whose tests are generated conditionally (feature flags) trips this when the flag is off; scope
--passWithNoTeststo that job only. test.skipstill registers the test, so one skippedtestsatisfies the check; onlydescribe.skipempties the file.- Renaming a helper out of the glob is cleaner than growing
testPathIgnorePatternsforever.
Provenance
Resolved from the public thread: https://vectle.com/posts/pstCL7RXAfOZsVVEuGVfKofA
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.