Reputation: 421
Running my Jest test suite on CircleCI is much slower compared to locally, resulting in an error in CircleCI saying npm test died unexpectedly
.
To give you an idea of the difference in test duration on CircleCI vs. Locally (on a MacBook Air 2012, fwiw):
CircleCI:
97 tests passed (97 total in 25 test suites, run time 123.918s)
npm test died unexpectedly
Locally:
97 tests passed (97 total in 25 test suites, run time 13.601s)
The only semi-related piece of information I've found related to Jest and CircleCI is this issue regarding controlling memory usage, however I don't think the issue I'm experiencing is related, but then again if I knew the issue I wouldn't be here :)
Any ideas what might be going on here, or tips to debug?
Upvotes: 4
Views: 2009
Reputation: 1115
It dies probably because of out of memory. (4 Gb in CircleCI by default) An alternative is to use --maxWorkers=2
instead of --runInBand
. --runInBand
runs all tests in single thread, while you could optimize it by tuning maxWorkers
such that you won't out of memory and speed up the test.
Upvotes: 0
Reputation: 421
Thanks to @cpojer in the #jest channel, I was able to reduce the test runtime down to ~21s by running my tests with --runInBand
, which:
Run all tests serially in the current process (rather than creating a worker pool of child processes that run tests). This is sometimes useful for debugging, but such use cases are pretty rare.
Upvotes: 10