Mocha "0 passing" / no tests executed in CI
Mocha started and exited cleanly but executed nothing: it reports "0 passing". Either no files matched the spec glob, or the files loaded but registered no it cases.
What this error means
The Mocha step prints "0 passing (1ms)" and exits 0, so CI reports green while nothing was actually tested. It commonly follows moving test files or changing the spec path.
Mocha output
0 passing (1ms)
(no test files were matched, or no it() blocks registered)Common causes
The spec glob matched no files
Mocha defaults to ./test/*.spec.js; if your tests live elsewhere or use a different extension, nothing is loaded.
Files loaded but defined no tests
A setup-only file, a skipped suite, or a syntax path that never reaches it() leaves Mocha with zero registered tests.
How to fix it
Point Mocha at the real spec paths
- Set the spec glob in
.mocharcor on the command line to match your test files. - Include the right extensions and recursive directories.
- Re-run and confirm the passing count is non-zero.
.mocharc.json
// .mocharc.json
{
"spec": "test/**/*.test.js",
"recursive": true
}Fail the build when zero tests run
Have CI treat an empty run as a failure so a green "0 passing" cannot hide a misconfigured path.
Terminal
npx mocha 'test/**/*.test.js' --recursiveHow to prevent it
- Define
specexplicitly in.mocharcso test discovery is deterministic. - Treat zero collected tests as a failure in CI.
- Keep the spec glob in sync when you move test files.
Related guides
Mocha "Ensure the done() callback is being called" timeout in CIFix Mocha "Timeout of 2000ms exceeded ... Ensure the done() callback is being called, or a promise is returne…
Mocha "before all" hook failure aborts the suite in CIFix Mocha "before all" hook failures in CI - when a top-level beforeEach/before hook throws, Mocha skips the…
Jest watch mode hangs with no TTY in CIFix Jest watch mode hanging in CI - "jest --watch" waits for keypresses on a TTY that CI does not have, so th…