Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest cant find any test with 23.2.0 #6546

Closed
aldarund opened this issue Jun 25, 2018 · 15 comments · Fixed by #6650 or #6661
Closed

Jest cant find any test with 23.2.0 #6546

aldarund opened this issue Jun 25, 2018 · 15 comments · Fixed by #6650 or #6661

Comments

@aldarund
Copy link
Contributor

aldarund commented Jun 25, 2018

🐛 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
@sqal
Copy link

sqal commented Jun 26, 2018

Same problem on Windows, CI passing :(

@erikrenberg
Copy link

erikrenberg commented Jun 26, 2018

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

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\\

@erikrenberg
Copy link

After digging a bit I think this issue is related to #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).

@SimenB
Copy link
Member

SimenB commented Jun 27, 2018

@thymikee ^

I suck at regexes :(

@aldarund
Copy link
Contributor Author

@erikrenberg ye its probably due to micromatch. See this comment -> babel/babel#8184 (comment)

@JoshuaKGoldberg
Copy link
Contributor

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

@SimenB
Copy link
Member

SimenB commented Jul 4, 2018

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

@JoshuaKGoldberg
Copy link
Contributor

JoshuaKGoldberg commented Jul 4, 2018

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

@NMinhNguyen
Copy link

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

@Vinnl
Copy link
Contributor

Vinnl commented Jul 9, 2018

A PR to revert to the older version was also suggested in #6563 (comment)

@SimenB
Copy link
Member

SimenB commented Jul 9, 2018

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

thymikee pushed a commit that referenced this issue Jul 9, 2018
## Summary

As part of #6400, `micromatch` was updated.  While `micromatch`'s CHANGELOG claims that this is safe, several regressions have been noted in cases where users relied upon invalid glob patterns.  For example, these patterns would all match `src/foo/bar/baz.js`, but no longer do:

 - `src/**/*.{js}`
 - `src/**.js`
 - `src/**/*.{js|ts}`

Fixes #6563
Fixes #6546

## Test plan

Unit tests were added which demonstrate the known cases.
@cronning9
Copy link

cronning9 commented Sep 12, 2018

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

@Vinnl
Copy link
Contributor

Vinnl commented Sep 12, 2018

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

@dtuyenle
Copy link

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

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants