Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest incorrectly exits 0 when no tests are found #5092

Closed
LINKIWI opened this issue Dec 16, 2017 · 3 comments
Closed

Jest incorrectly exits 0 when no tests are found #5092

LINKIWI opened this issue Dec 16, 2017 · 3 comments

Comments

@LINKIWI
Copy link
Contributor

LINKIWI commented Dec 16, 2017

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
@SimenB
Copy link
Member

SimenB commented Dec 16, 2017

Can you send a PR with a fix?

@SimenB
Copy link
Member

SimenB commented Dec 16, 2017

Actually, this was fixed in #3672

Please install jest@test to use it. A stable release is coming early next week

@SimenB SimenB closed this as completed Dec 16, 2017
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants