Skip to content

react-scripts test (or Jest) is reporting exit code 0 on test failures #7180

Closed

Description

@thedanchez

Is this a bug report?

Possibly

Did you try recovering your dependencies?

Yes

Environment

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

Steps to Reproduce

  1. Create a CRA project with tests
  2. Create a bash script that encapsulates the react-scripts test command execution
  3. Output the exit code result from within that wrapping bash script

Expected Behavior

I expect the exit code to be non-zero when tests fail

Actual Behavior

react-scripts test is reporting a 0 exit code

Reproducible Demo

None yet

Activity

  1. bugzpodder commented on Jun 6, 2019

    @bugzpodder

    You can try setting CI=true to get a non-zero exit code.

  2. heyimalex commented on Jun 6, 2019

    @heyimalex
    Contributor

    Duplicate of #7026 I think. Last time I checked we're doing everything right, but jest doesn't return the appropriate error code.

  3. thedanchez commented on Jun 6, 2019

    @thedanchez
    Author

    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.

  4. changed the title [-]react-scripts test is not reporting non-zero exit code on test failures (when running inside a bash script)[/-] [+]react-scripts test (or Jest) is reporting exit code 0 on test failures[/+] on Jun 6, 2019
  5. goranefbl commented on Jun 10, 2019

    @goranefbl

    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.

  6. silverwind commented on Jun 27, 2019

    @silverwind

    Confirmed, steps to reproduce:

    $ npx create-react-app exittest
    $ cd exittest
    $ echo fail > src/App.js
    $ npx react-scripts test --watchAll=false
    $ echo $?
    0
  7. added this to the 3.1 milestone on Jun 27, 2019
  8. bugzpodder commented on Jun 27, 2019

    @bugzpodder

    I think add --bail works as others pointed out

  9. silverwind commented on Jun 27, 2019

    @silverwind

    Imho, a proper exit code should be set by default and not only with obscure arguments like --bail.

  10. bugzpodder commented on Jun 27, 2019

    @bugzpodder

    Agreed, PRs welcome!

  11. mAAdhaTTah commented on Jul 19, 2019

    @mAAdhaTTah

    Also --bail will stop running tests on the first error, rather than running the full test suite then erroring.

  12. modified the milestones: 3.2, 3.1 on Jul 26, 2019
  13. self-assigned this
    on Jul 26, 2019
  14. added a commit that references this issue on Jul 26, 2019
    8b30eee
  15. added a commit that references this issue on Jul 26, 2019
    cbad256
  16. locked and limited conversation to collaborators on Jul 31, 2019
  17. added a commit that references this issue on Nov 21, 2019
    bffe42e
  18. added a commit that references this issue on Jan 3, 2020
    d4d5df6
  19. added a commit that references this issue on Apr 10, 2020
    5b562e9
  20. added a commit that references this issue on Oct 8, 2024
    45e125f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions