Is jest fully scanning node_modules and then ignoring its content by default ?
See original GitHub issue⚡ Performance improvement ?
Jest has been slow to start on my computer, which has a relatively slow filesystem (windows ntfs and a few layers of encryption).
Reading the default configuration, I’m wondering whether jest scans every file in the <rootDir> and then ignores the ones in node_modules. I replaced my roots with <rootDir>/src/ instead of <rootDir> and it feels faster.
To Reproduce
- Develop a javascript project with a lot of npm dependencies with many files on a slow filesystem.
- Run jest with no config.
- Run jest with
roots: ['<rootDir>/src/']in its config.
Expected behavior
Jest should scan the files to find the tests relatively fast. But by default I’m not sure it’s the case.
envinfo
System:
OS: Windows 10 10.0.18363
CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^25.4.0 => 25.4.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:12
Top Results From Across the Web
Configuring Jest
The directory where Jest should output its coverage files. coveragePathIgnorePatterns [array<string>]. Default: ["/node_modules/"]. An array of regexp pattern ...
Read more >jest ignore all node_modules except 1 package - Stack Overflow
this basically says, ignore all node_modules except my-package. However, the thing to note here is, testPathIgnorePatterns does not determine ...
Read more >Configuring Jest compiled - w3resource
Jest will attempt to scan your dependency tree once (up-front) and cache it so as to ease some of the filesystem raking that...
Read more >wordpress/scripts | Block Editor Handbook
When using the start or build commands, the source code directory ( the default is ./src ) and its subdirectories are scanned for...
Read more >Generating code coverage report in Jest
If test coverage is enforced with some additional analysis about the quality of tests, defect clustering, and other parameters that can ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

See also this config change for watchman so that it ignores node_modules. That speeds up the initial run significantly: https://github.com/facebook/jest/issues/10833#issuecomment-741748347
Also worth mentioning that last saved index must be available in jest cache and cache key must be valid otherwise it builds index again.
And completely agree that it should be evident from CLI that indexing is happening and in documentation I think it should be stated how to avoid it.
From
jest-haste-mapcode: