Jest: Misleading message for passWithNoTests.

Created on 21 Mar 2019  路  6Comments  路  Source: facebook/jest

馃悰 Bug Report

The same message appears regardless of --passWithNoTest being specified or not:
No tests found, exiting with code 1
Run with --passWithNoTests to exit with code 0

Please note, that the response code is indeed correct: with --passWithNoTest it is 0, without - it is 1.

It's in runJest.ts line 204 or 215 - call to getNoTestsFoundMessage() function. Or in that function itself.

To Reproduce

Run jest against any project with no tests or no tests matching the pattern. See the console output.

Expected behavior

The printed message should reflect the reality. When no tests found and --passWithNoTests specified it should either not be present at all or should read:
No tests found, exiting with code 0

Link to repl or repo (highly encouraged)

N/A

Run npx envinfo --preset jest

N/A

Bug Confirmed Help Wanted Needs Triage good first issue

Most helpful comment

Yeah, go for it!

All 6 comments

There's a reason we ask for reproductions - this works like it should in Jest's repo:

$ y jest blahblah
yarn run v1.15.0
$ node ./packages/jest-cli/bin/jest.js blahblah
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/simen/Development/jest
  2151 files checked across 14 projects. Run with `--verbose` for more details.
Pattern: blahblah - 0 matches
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ echo $?
1
$ y jest blahblah --passWithNoTests
yarn run v1.15.0
$ node ./packages/jest-cli/bin/jest.js blahblah --passWithNoTests
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/simen/Development/jest
  2151 files checked across 14 projects. Run with `--verbose` for more details.
Pattern: blahblah - 0 matches
$ echo $?
0

Could you setup a reproduction and include what commands you run at their exit code?

@SimenB You've reproduced it perfectly well! As the bug description says, the exit code is just fine in both scenarios. But in the latter one there should be no console message at all or it should be different. It did actually return 0, but says that it did return 1, etc.

Ah, it's _just_ the message! Gotcha, I thought you said the flag didn't work. Sorry about that.

Yeah that's a bug 馃檪

@SimenB Can I take this up 馃檪

Yeah, go for it!

8595

Was this page helpful?
0 / 5 - 0 ratings