Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

Jest doesn't find any test files on windows #21

Closed
DorianGrey opened this issue Jun 27, 2018 · 6 comments
Closed

Jest doesn't find any test files on windows #21

DorianGrey opened this issue Jun 27, 2018 · 6 comments

Comments

@DorianGrey
Copy link
Owner

Just recognized the appveyor build failing after the most recent update of jest to 23.2.0.

There are already a couple of issues open regarding this:
jestjs/jest#6546
jestjs/jest#6509

Have to figure out if it's possible to work around this using a different testMatch config.

@wesleythomaswilliams
Copy link

wesleythomaswilliams commented Sep 18, 2018

@DorianGrey Didn't know where best to ask this, but I'm having trouble with jest finding any test files on Win10 using 23.6.0. Even when I pass in a direct path to a test file (rather than wildcards in testMatch) it fails to find it. Didn't want to raise a new bug in case I was being really dense. Would appreciate any help you can give.

Example with direct path trying with win & linux paths:

e.g.
$ node_modules/.bin/jest C:\Users\WESLEYWilliams\git\myrepo\test\fvt\__ tests __\my.test.js
No tests found
No files found in C:\Users\WESLEYWilliams\git\myrepo.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern: C:\Users\WESLEYWilliams\git\myrepo\test\fvt\ __ tests __\my.test.js - 0 matches

$ node_modules/.bin/jest /c/Users/WESLEYWilliams/git/myrepo/test/fvt/__ tests __ /my.test.js
No tests found
No files found in C:\Users\WESLEYWilliams\git\myrepo.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern: C:\Users\WESLEYWilliams\git\myrepo\test\fvt\ __ tests __\my.test.js - 0 matches

@DorianGrey
Copy link
Owner Author

I've checked this on Win 10, and both ways of providing a file path resp. pattern work fine, i.e. I cannot reproduce this issue, neither on jest 23.5 nor on 23.6.
Additional details on your project would be useful, i.e. a repo to reproduce this issue with.

@wesleythomaswilliams
Copy link

@DorianGrey Unfortunately I can't share the repo, but what kind of project details might I be able to provide that could help?

@wesleythomaswilliams
Copy link

wesleythomaswilliams commented Sep 19, 2018

@DorianGrey My colleague (on Mac) and I (on Win10) both created a basic repo each. He can run jest in both mine and his repo fine and it finds the test, I run jest and it doesn't in either

My result in my repo:

$ node_modules/.bin/jest
No tests found
No files found in C:\Users\WESLEYWilliams\git\jesttest.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern:  - 0 matches

His result in my repo:

$ jest
 FAIL  test/fvt/__tests__/version.test.js
  ● Test suite failed to run

    Your test suite must contain at least one test.

      at node_modules/jest-cli/build/TestScheduler.js:256:22

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.713s
Ran all test suites.

We've tried versions 23.1.0 and 23.6.0

My repo: https://github.com/wideawakewesley/jesttest
His repo: https://github.ibm.com/Arron-Harden/jest-filematch-issue

@DorianGrey
Copy link
Owner Author

It seems to have something to do with the roots property. When removing it, I also get the latter result on Win10. The same result occurs when changing to array to only reference the test folder, like:

"roots": [
   "<rootDir>/test/"
 ]

In general - is there any particular reason to define rootDir and roots explicitly? In most cases, this is not required.
Side note: The patterns you have defined for testMatch appear a bit weird, suppose you want to cover js and jsx files, and not jx, right? At least the patterns mention that the s is optional, so .jx would be a covered file extension. jsx? should be more useful in this case.

@wesleythomaswilliams
Copy link

@DorianGrey Thanks, that cracked it! Really appreciate the help. Also particularly like the user icon. Happens to be my favourite character from a book series I loved as a kid.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants