Closed
Description
This behavior is reproducible on [email protected]
.
Actual behavior
When attempting to run tests against a directory that is nonexistent (or even a directory that exists, but does not contain any valid tests), the CLI exits 0.
Expected behavior
The CLI should exit nonzero when there is an error identifying tests.
Motivation
This is problematic for CI/automated environments where test success is determined based on exit code. Semantically, it is a valid error condition if CI isn't able to find any tests to run. This surfaced after performing a major refactor that changed a project's test directory structure, and CI still passed the build despite the jest
step failing to identify any tests.
Minimally reproducible example
$ yarn add jest
$ mkdir test
$ ./node_modules/.bin/jest --verbose test
No tests found
In /path/to/test
6 files checked.
testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 0 matches
testPathIgnorePatterns: /node_modules/ - 6 matches
Pattern: test - 0 matches
$ echo $?
0
Metadata
Metadata
Assignees
Labels
No labels