jest: Jest cant find any test with 23.2.0

🐛 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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 23
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

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”.

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

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

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.

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

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

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).

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 transformIgnorePatterns for testPathIgnorePatterns which does indeed work as it should (however, the original issue still remains).

<del>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). </del>

<del>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: </del>

<del>> testPathIgnorePatterns: \\node_modules\\ </del>