Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error running Jest on CircleCI: "npm test died unexpectedly"

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?

like image 962
sawyer Avatar asked Dec 25 '22 06:12

sawyer


1 Answers

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.

like image 82
sawyer Avatar answered Feb 15 '23 11:02

sawyer