find tests when path includes folder starting with a period
See original GitHub issueš Bug Report
This is a regression of the bug reported in #3111 that was fixed in #3006 and broke again sometime in the v23 branch.
When a test is inside a folder that has a name starting with period, .
, they are ignored by testMatch
and by testRegex
. Itās even more obscure if the entire project is checked out below a dot-folder, in which case all tests are ignored.
To Reproduce
Given the following directory listing:
~/projects/jestbug/.app/__tests__/atest.js
~/projects/jestbug/.app/atest.test.js
~/projects/jestbug/app/atest.test.js
~/projects/jestbug/app/.subfolder/__tests__/atest.js
~/projects/jestbug/app/.subfolder/atest.test.js
~/projects/jestbug/app/__tests__/atest.js
~/projects/jestbug/atest.test.js
Using the following package.json
:
{
"name": "jestbug",
"devDependencies": {
"jest": "^23.6.0"
}
}
None of the tests in a folder staring with .
are found:
$ rm -rf node_modules
$ npm install
$ npx jest --listTests --no-cache
~/projects/jestbug/atest.test.js
~/projects/jestbug/app/atest.test.js
~/projects/jestbug/app/__tests__/atest.js
Using the following package.json
:
{
"name": "jestbug",
"devDependencies": {
"jest": "^23.6.0"
},
"jest": {
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$"
}
}
None of the tests in a folder staring with .
are found:
$ rm -rf node_modules
$ npm install
$ npx jest --listTests --no-cache
~/projects/jestbug/atest.test.js
~/projects/jestbug/app/atest.test.js
~/projects/jestbug/app/__tests__/atest.js
Expected behavior
Using the following package.json
:
{
"name": "jestbug",
"devDependencies": {
"jest": "^22.4.4"
}
}
$ rm -rf node_modules
$ npm install
$ npx jest --listTests --no-cache
~/projects/jestbug/app/atest.test.js
~/projects/jestbug/.app/atest.test.js
~/projects/jestbug/app/.subfolder/atest.test.js
~/projects/jestbug/atest.test.js
~/projects/jestbug/app/.subfolder/__tests__/atest.js
~/projects/jestbug/app/__tests__/atest.js
~/projects/jestbug/.app/__tests__/atest.js
Using the following package.json
:
{
"name": "jestbug",
"devDependencies": {
"jest": "^22.4.4"
},
"jest": {
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$"
}
}
$ rm -rf node_modules
$ npm install
$ npx jest --listTests --no-cache
~/projects/jestbug/app/atest.test.js
~/projects/jestbug/.app/atest.test.js
~/projects/jestbug/app/.subfolder/atest.test.js
~/projects/jestbug/atest.test.js
~/projects/jestbug/app/.subfolder/__tests__/atest.js
~/projects/jestbug/app/__tests__/atest.js
~/projects/jestbug/.app/__tests__/atest.js
Link to repl or repo (highly encouraged)
Note that repl.it currently uses Jest v22 and I canāt figure out how to make it run under v23.
But hereās the demo link where the bug is NOT present because v22 is not broken. https://repl.it/@John_AlbinAlbin/CarpalSoulfulDirectories
Run npx envinfo --preset jest
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
Yarn: 1.10.1 - ~/.yarn/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
npmPackages:
jest: ^23.6.0 => 23.6.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:14 (1 by maintainers)
This bug made me question my sanity at first too.
FYI, because of the Jest cache issues, thatās exactly what was happening to my team. My co-worker saw the bug and I didnāt. Then finally I did see the bug, but after a day it disappeared. Then reappeared. However, we always used Yarn (not npm). AND, the tests that were being skipped were ones that we put in our
.storybook
folder.You can restart watchman by doing
watchman watch-del $PWD
orwatchman watch-del-all
(will remove all other projects crawl cache, if they use watchamn).