Speeding up Jest tests with –runInBand

This weekend, I started writing front-end tests for a few new components. I immediately hit a hiccup in the form of a dreadfully slow test suite. This didn’t make much sense to me because I only had a few simple tests at the time. With my local Docker …


This content originally appeared on Jonnie Hallman (@destroytoday) and was authored by Jonnie Hallman (@destroytoday)

This weekend, I started writing front-end tests for a few new components. I immediately hit a hiccup in the form of a dreadfully slow test suite. This didn’t make much sense to me because I only had a few simple tests at the time. With my local Docker setup, I was seeing test runs taking anywhere between 10 seconds and 80 seconds for maybe five tests. This seemed insane—even considering the fastest time I experienced.

After a bit of searching, I came across a thread with some folks suggesting Jest’s runInBand option. This tells Jest to run the tests serially in the current process rather than creating a worker pool and parallelizing the tests across several workers. It’s especially useful for environments with limited resources, which would make sense for why it helped my Docker container. One commenter indicated that --runInBand reduced their test time from over 1.5 hours down to 4 minutes! It really makes me wonder why this option isn’t the default, leaving the worker pool to be opted into.

Reply via email


This content originally appeared on Jonnie Hallman (@destroytoday) and was authored by Jonnie Hallman (@destroytoday)


Print Share Comment Cite Upload Translate Updates
APA

Jonnie Hallman (@destroytoday) | Sciencx (2020-07-06T08:09:00+00:00) Speeding up Jest tests with –runInBand. Retrieved from https://www.scien.cx/2020/07/06/speeding-up-jest-tests-with-runinband-2/

MLA
" » Speeding up Jest tests with –runInBand." Jonnie Hallman (@destroytoday) | Sciencx - Monday July 6, 2020, https://www.scien.cx/2020/07/06/speeding-up-jest-tests-with-runinband-2/
HARVARD
Jonnie Hallman (@destroytoday) | Sciencx Monday July 6, 2020 » Speeding up Jest tests with –runInBand., viewed ,<https://www.scien.cx/2020/07/06/speeding-up-jest-tests-with-runinband-2/>
VANCOUVER
Jonnie Hallman (@destroytoday) | Sciencx - » Speeding up Jest tests with –runInBand. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2020/07/06/speeding-up-jest-tests-with-runinband-2/
CHICAGO
" » Speeding up Jest tests with –runInBand." Jonnie Hallman (@destroytoday) | Sciencx - Accessed . https://www.scien.cx/2020/07/06/speeding-up-jest-tests-with-runinband-2/
IEEE
" » Speeding up Jest tests with –runInBand." Jonnie Hallman (@destroytoday) | Sciencx [Online]. Available: https://www.scien.cx/2020/07/06/speeding-up-jest-tests-with-runinband-2/. [Accessed: ]
rf:citation
» Speeding up Jest tests with –runInBand | Jonnie Hallman (@destroytoday) | Sciencx | https://www.scien.cx/2020/07/06/speeding-up-jest-tests-with-runinband-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.