Jest Unit Test Loves CPU Core So Much

I was feeling that my computer running slow, current running on Intel i3 12100f with 4c/8t. I have around 531 test case of jest (typical react/next js projects), running it with default params like this:

jest --updateSnapshot --detectOpenHandles

... will take around 3 minutes 14 seconds to complete. In the future, the test case will be added, possibly reach a thousand++ in Q3 of 2024. This is not good. I rerun it with some additional parameters, it helps to reduce it a few seconds but not much. Here is my data of it (CLICK HERE).

I have older device running with Ryzen 4500u with 6 core and 6 thread, after testing it, it is much-much faster that 4c/8t i3 12100f.

Seems like jest dont really take an advantage of fast core, which i believe when running the task, it only took 30% of the cpu to running the test case.

--runInband in i3 12100f

They just love more cores! The performance (single thread performance) Ryzen 4500u is slower than my i3 12100f, but still faster because they have two more cores!

As far as I know we cant really do anything, probably simplify the unit test case, reduce mocking can help but not much. Only have more core that can add significant time reduces

Post a Comment