Create-react-app: Tests exiting code 1 when no tests are found

Created on 3 Oct 2018  Â·  2Comments  Â·  Source: facebook/create-react-app

Is this a bug report?

Yes

Did you try recovering your dependencies?

N/A

Which terms did you search for in User Guide?

test, tests, ci, jest

Environment

Noticed on CI server but also happening locally.

using react-scripts v2

Steps to Reproduce

  1. Run yarn test from project without tests.

Expected Behavior

Shouldn't exit code 0 or have a flag to enable/disable the behavior

Actual Behavior

Exited code 1

❯ cross-env CI=true yarn test --ci
yarn run v1.9.4
$ react-scripts test --ci
No tests found
In /Users/stramel/Projects/my-package
  9 files checked.
  testMatch: /Users/stramel/Projects/my-package/src/**/__tests__/**/*.{js,jsx},/Users/stramel/Projects/my-package/src/**/?(*.)(spec|test).{js,jsx} - 0 matches
  testPathIgnorePatterns: /node_modules/ - 9 matches
Pattern:  - 0 matches
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
question

Most helpful comment

This was an intentional change made in Jest. You can add add a flag to turn this behavior off, i.e.:

{
  "scripts": {
    "test": "react-scripts test --passWithNoTests"
  }
}

All 2 comments

This was an intentional change made in Jest. You can add add a flag to turn this behavior off, i.e.:

{
  "scripts": {
    "test": "react-scripts test --passWithNoTests"
  }
}

Thanks @Timer! Sorry didn't see any documentation about how to bypass it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrice727 picture adrice727  Â·  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  Â·  3Comments

wereHamster picture wereHamster  Â·  3Comments

JimmyLv picture JimmyLv  Â·  3Comments

barcher picture barcher  Â·  3Comments