Create-react-app: Unit tests are not executed

Created on 2 Aug 2017  Â·  7Comments  Â·  Source: facebook/create-react-app

Is this a bug report?

Yes

Can you also reproduce the problem with npm 4.x?

I am using latest yarn 0.27.5 and npm 5.2.0 on Windows.

Environment

Steps to Reproduce

  1. Run yarn test or npm test (is running script react-scripts test --env=jsdom)
  2. It says: "Determining test suites to run..." -> "Press a to run all tests."
  3. After hitting a

  4. You see:

No tests found
In C:\PROJECT
  18490 files checked.
  testMatch: C:\PROJECT\src\**\__tests__\**\*.js?(x),C:\PROJECT\src\**\?(*.)(spec|test).js?(x) - 6 matches
  testPathIgnorePatterns: \\node_modules\\ - 18490 matches
Pattern: "" - 0 matches

No tests were executed but there are tests inside in PROJECT/src/ eg. default App.test.js - these tests are being executed when saving changes while in jest watch mode.

Expected Behavior

All tests inside src/**/*.test.js should be executed

Note (Temporary workaround)

Using Windows 10 bash (ubuntu) it's running fine, so looks like it affects only Windows (tested on both - Win 7 & 10)

bug underlying tools

Most helpful comment

Seems like this is fixed on Jest 22 so I'll close. We'll update to it soon.

As a temporary workaround you can run your tests with --no-watchman, i.e. npm test -- --no-watchman.

All 7 comments

Hello. I can confirm this issue on my machine as well. Thanks to the note's temporary workaround (using bash), I'm able to execute my tests again.

My machine is running:

  • Microsoft Windows 10 Enterprise (x64)
  • Version 10.0.14393 Build 14393

To make sure the issue isn't caused by my project's setup, I created a clean create-react-app project in C:\my-app. The output of running all tests in an admin cmd prompt:

No tests found
In C:\my-app
  14439 files checked.
  testMatch: C:\my-app\src\**\__tests__\**\*.js?(x),C:\my-app\src\**\?(*.)(spec|test).js?(x) - 1 match
  testPathIgnorePatterns: \\node_modules\\ - 14439 matches
Pattern: "" - 0 matches

The "1 match" will have to be the default src/App.test.js file, created when running the create-react-app command. Still, no test is actually executed and the "No tests found" output is shown.

When run using bash on Windows, the output is:

yarn test v1.0.2
$ react-scripts test --env=jsdom
  console.error node_modules\fbjs\lib\warning.js:33
    Warning: React depends on requestAnimationFrame. Make sure that you load a polyfill in older browsers. http://fb.me/react-polyfills

 PASS  src\App.test.js
  √ renders without crashing (24ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.772s
Ran all test suites related to changed files.

Hi,
I solved this issue by removing the locally installed watchman path variable. When running jest --verbose I got "@providesModule naming collision" warnings as reported in issue.
After removing the variable, jest is matching and executing all tests again.
Maybe this workaround helps some of you.
My system is running:

  • Microsoft Windows 10 Enterprise (x64)
  • Version 10.0.15063 Build 15063

Thank you very much @zehbauer, removing watchman from my path env-var worked!

I'll close as that doesn't appear to be an issue on our side.

I can also reproduce this with a computer that has C:\tools\watchman in its %PATH%.

Seems like we should at least figure out what’s causing this.

Seems like this is fixed on Jest 22 so I'll close. We'll update to it soon.

As a temporary workaround you can run your tests with --no-watchman, i.e. npm test -- --no-watchman.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrice727 picture adrice727  Â·  3Comments

ap13p picture ap13p  Â·  3Comments

Aranir picture Aranir  Â·  3Comments

barcher picture barcher  Â·  3Comments

rdamian3 picture rdamian3  Â·  3Comments