Jest: Jest cant find any test with 23.2.0

Created on 25 Jun 2018  ·  14Comments  ·  Source: facebook/jest

🐛 Bug Report

Jest cant find any test with 23.2.0 . If revert back to 23.1.0 - it find all test

No tests found
In C:\Dev\PycharmProjects\rasimplefront\ra-front-simple-nu
  145 files checked.
  testMatch: C:\Dev\PycharmProjects\rasimplefront\ra-front-simple-nu\(tests\unit\**\*.spec.(js|jsx|ts|tsx)|**\__tests__\*.(js|jsx|ts|tsx)) - 0 matches
  testPathIgnorePatterns: \\node_modules\\ - 145 matches

To Reproduce

I have following testMatch in jest.config

  testMatch: [
    '<rootDir>/(tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx))'
  ],

Example of test file location tests\unit\components\loginForm.spec.js

Expected behavior

tests found and executed like in 23.1.0

Run npx envinfo --preset jest

  System:
    OS: Windows 10
    CPU: x64 AMD Ryzen 7 1700X Eight-Core Processor
  Binaries:
    Yarn: 1.7.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.1.0 - C:\Program Files\nodejs\npm.CMD

Most helpful comment

Did this fix actually work for anybody? I've spent hours trying to get this to work...

I went so far as to drop my only testMatch glob to "**/**.test.ts", which is very obviously a match for "__tests__/index.test.ts". But still that message, "No tests found".

All 14 comments

Same problem on Windows, CI passing :(

Same problem here (also on Windows, npm 6.1.0, node 8.11.3), with the following match:

"testMatch": [
      "<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
      "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
    ],

Update: Ignore the strikethrough part below: I confused transformIgnorePatternsfor testPathIgnorePatternswhich does indeed work as it should (however, the original issue still remains).

Update: It doesn't seem that it uses transformIgnorePatterns correctly, because it apparently matches all tests against that (see the original post in the thread). Changing transformIgnorePatterns to something else that should match nothing - for example "ABCDEFG1234" doesn't seem to work either, it still uses exactly what the original post above says: > testPathIgnorePatterns: \\\\node_modules\\\\

After digging a bit I think this issue is related to https://github.com/facebook/jest/pull/6400 which updated the dependency micromatch to the latest version. I don't know why though…

(I was able to get our tests to run with jest 23.2.0 by removing testMatch completely, which presumably falls back to some default which works).

@thymikee ^

I suck at regexes :(

@erikrenberg ye its probably due to micromatch. See this comment -> https://github.com/babel/babel/issues/8184#issuecomment-398516685

@SimenB could you please revert the upgrade that brought in micromatch? This is a very breaking change.

I think that makes sense. Wanna send a PR reverting back to micromatch 2?

We also need to add an integration test, as none of our tests caught this. None on the team uses Windows, so we rely on Appveyor CI to tell us that changes are safe for Windows as well

I won't be able to until the 5th or 6th, if it hasn't been sent by then will do!

Edit: #6650 sent by someone else :)

Just a theory, but I think the reason why micromatch was updated could be due to a regex Denial of Service vulnerability: see https://github.com/babel/babel/pull/8038 for a similar PR in Babel that upgraded micromatch.

A PR to revert to the older version was also suggested in https://github.com/facebook/jest/issues/6563#issuecomment-403171406

I still think we should revert, event though we work around some of the changes by replacing separators

Did this fix actually work for anybody? I've spent hours trying to get this to work...

I went so far as to drop my only testMatch glob to "**/**.test.ts", which is very obviously a match for "__tests__/index.test.ts". But still that message, "No tests found".

Yes, which is why nobody else responded when this was fixed. Try asking your question on StackOverflow or reporting a new bug :)

I am not sure why such a simple recursively check for test would be this complicated ? Other test platform don't have this problem.

Was this page helpful?
0 / 5 - 0 ratings