Possibly
Yes
System:
OS: macOS High Sierra 10.13.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
Browsers:
Chrome: 75.0.3770.80
Firefox: 66.0.2
Safari: 12.1
npmPackages:
react: ^16.6.3 => 16.6.3
react-dom: ^16.6.3 => 16.6.3
react-scripts: 2.1.8 => 2.1.8
npmGlobalPackages:
create-react-app: Not Found
react-scripts test command executionI expect the exit code to be non-zero when tests fail
react-scripts test is reporting a 0 exit code
None yet
You can try setting CI=true to get a non-zero exit code.
Duplicate of #7026 I think. Last time I checked we're doing everything right, but jest doesn't return the appropriate error code.
Setting the CI env variable works but the usage of that for local test runs doesn't seem right to me. We also lose the pretty output.
Been digging around for the past couple of hours and found that adding --bail in the CLI works as well.
I think its the same problem as #6944
I have a Husky configured and without CI env, even though tests are failing, Husky is not stopping commits from going through. Adding of CI works, but as @thedanchez pointed out, we are losing pretty output.
Update:
Seems that --bail keeps the pretty output.
Confirmed, steps to reproduce:
console
$ npx create-react-app exittest
$ cd exittest
$ echo fail > src/App.js
$ npx react-scripts test --watchAll=false
$ echo $?
0
I think add --bail works as others pointed out
Imho, a proper exit code should be set by default and not only with obscure arguments like --bail.
Agreed, PRs welcome!
Also --bail will stop running tests on the first error, rather than running the full test suite then erroring.
Most helpful comment
Imho, a proper exit code should be set by default and not only with obscure arguments like
--bail.