-
-
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 suggestion of using --passWithNoTests on no tests found #5127
Add suggestion of using --passWithNoTests on no tests found #5127
Conversation
3dcf491
to
5f31553
Compare
Codecov Report
@@ Coverage Diff @@
## master #5127 +/- ##
======================================
Coverage 60.8% 60.8%
======================================
Files 201 201
Lines 6707 6707
Branches 3 3
======================================
Hits 4078 4078
Misses 2628 2628
Partials 1 1
Continue to review full report at Codecov.
|
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.
Thanks for the PR!
I think this warning only makes sense if findRelatedTests
is passed. A full test run not finding any tests should just be considered an error.
It's also a bit verbose, even though I don't have any better suggestion off the top of my head.
A test (integration test is fine) for this would also be needed.
And an update to the changelog
I guess we could maybe do something more along the lines of
Yep, as I asked in the original PR message I was just a bit in doubt about whether this counted as a fix, feature, or a chore. But now that we're adding logic regarding other options etc. I guess I'm starting to lean towards feature?
That makes sense, as I guess any "constant" (non-dynamic) command should always find at least one tests or it should be removed from whatever script is being run. I was just looking through CLI options to see if there were any other dynamic CLI options, and I found |
Something like that?
Agreed
Sounds like it. @cpojer thoughts here? |
One could of course also consider just making it not error when using one of the dynamic options such as |
That might make sense. We've turned it off for watch mode already, extending that to |
Yeah I'd personally find that behavior nice and expected, especially for my use case of precommit hooks. So shall I implement it like that? Just making it exit with exit code 0 in the above mentioned "dynamic" cases? |
@cpojer (and @EnoahNetzach) what do you think? I'm leaning towards what I said in my last post, but I'd love to hear your thoughts on it |
Off the top of my head I could find usages where you want to use The |
I agree, let’s just not make it exit with 1 when one of those options are passed. |
Okay so that's a 2 - 1 vote for changing exit code as opposed to just a warning message from the contributors. Is that final? |
Yes |
Okay, I'll get around to implementing it in the near future then. Will enjoy celebrating Christmas with the family first though! Happy holidays to all that celebrate something :) |
5f31553
to
ab94aa4
Compare
Okay, back to work after holidays :). I pushed the changes and update to the CHANGELOG. The only thing I could think that one could do different is add a message in our special case that lets the user know that we aren't erroring, but I think in my opinion it's probably okay to leave that out as it is still obviously stated that there are no tests found, and as we discussed above it seems to be the intuitive behavior for it not to error. This should definitely have some simple tests though, but I was looking at it a bit and it's just a big folder structure of tests and I got a bit lost so I thought I might ask for some suggestions where to put the tests? If there is a file / directory that I could just integrate it into or whether I should make a new one (and if so where)? I'm assuming there are already tests that check that it errors correctly in usual circumstances (though I just did a Thanks! And happy New Year! |
@emilgoldsmith Sorry about the slow response! I'd update the assertion in this test: https://github.com/facebook/jest/blob/e5b9339e23ae5d3e9713c8210d365a005de823e9/integration_tests/__tests__/pass_with_no_tests.test.js#L18-L25 |
ab94aa4
to
1be1adf
Compare
Thanks for the heads up @SimenB, just what I needed! I'm not sure what went wrong with the CI tbh, it looks like the problems happen in the restoring of cache? Everything runs fine on my computer. As far as I'm concerned I think I'm done now, so it should be ready for a final review :) |
CHANGELOG.md
Outdated
@@ -51,6 +51,9 @@ | |||
|
|||
* `[jest-config]` Add `forceCoverageMatch` to allow collecting coverage from | |||
ignored files. ([#5081](https://github.com/facebook/jest/pull/5081)) | |||
* `[jest-cli]` Make Jest exit without an error when no tests are found in |
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.
can you move this to be under master
at the top?
You probably need a rebase
const path = require('path'); | ||
const runJest = require('../runJest'); | ||
|
||
const DIR = path.resolve(__dirname, '../pass_with_no_tests-test'); |
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.
you should rename this directory as well since you're renaming this file
1be1adf
to
6ce7982
Compare
…ests, --lastCommit or --onlyChanged options
6ce7982
to
dfb0e33
Compare
Rebased and comments addressed |
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.
Not sure what's up with ci...
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
I just upgraded my version of Jest and encountered the breaking change regarding
No tests found
returning a non-zero error code, and after researching and figuring out the cause I thought that the message I added now would've been helpful, so I thought I'd suggest adding it.Test plan
Should'nt be much testing necessary here, but this is how it looks now:
Also a quick question regarding the CHANGELOG: Would this be a fix, feature or a chore?