-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add an option to fail if no tests are found #3672
Conversation
packages/jest-cli/src/runJest.js
Outdated
if (argv.failWithNoTests) { | ||
new Console(pipe, pipe).error(noTestsFoundMessage); | ||
|
||
process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the way it should be done.
Is it right?
Codecov Report
@@ Coverage Diff @@
## master #3672 +/- ##
==========================================
- Coverage 56.17% 56.14% -0.04%
==========================================
Files 191 191
Lines 6424 6428 +4
Branches 6 6
==========================================
Hits 3609 3609
- Misses 2812 2816 +4
Partials 3 3
Continue to review full report at Codecov.
|
I would prefer to make this the default, but have a way to opt-out of the feature. The reason we need this not to fail at FB is because our internal test runner currently sees more tests than Jest sees, so it would invoke Jest on files that aren't actual tests. Do you mind inverting this and making the default throw? |
Would you mind rebasing this PR? |
c87e010
to
99baa11
Compare
I'm rebasing right now, but I see a lot (37) of snapshot tests failing even if I stash my changes (after commit dfdca8b). Shell output for
|
Ci looks happy, anything holding this up? |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
By adding a
--failWithNoTests
the intent is to catch when no files are detected (for example used together with--testPathPattern
), so that CI can detect this and fail.This happened in Create React App for a while, and was virtually impossible to detect.
Test plan
I begun with adding a test case, verifying that it fails, then I'll add the feature.