Open
Description
openedon Feb 11, 2020
🐛 Bug Report
I did some profiling on a directory of 500 empty tests and discovered that Jest is spending 50% of its time importing jest-snapshot
into every test environment. Then I wrote a quick and dirty patch that rips jest-snapshot
out of jest-jasmine2
and jest-runtime
, and observed that it makes my tests run twice as fast (39.706s → 19.941s)!
Obviously we can’t actually rip jest-snapshot
out, but if we could import it lazily, we could get a large speedup on projects with many small test files that don’t use snapshot testing.
To Reproduce
In an empty directory:
mkdir __tests__
for i in {000..499}; do echo "test(\"test $i\", () => {});" > __tests__/test$i.js; done
echo '{ "testEnvironment": "node" }' > jest.config.json
jest --runInBand
(Running tests serially with --runInBand
gave me much more stable benchmark results.)
Expected behavior
Jest should be faster! 🙂
Link to repl or repo (highly encouraged)
https://github.com/andersk/500-empty-jest-tests
envinfo
System:
OS: Linux 5.5 NixOS 20.03 (Markhor) 20.03pre212208.8130f3c1c2b (Markhor)
CPU: (12) x64 Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz
Binaries:
Node: 12.15.0 - ~/.nix-profile/bin/node
Yarn: 1.22.0 - ~/.yarn/bin/yarn
npm: 6.13.4 - ~/.nix-profile/bin/npm
npmPackages:
jest: ^25.1.0 => 25.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment