nicolo-ribaudo / jest-light-runner

A Jest runner that runs tests directly in bare Node.js, without virtualizing the environment.
MIT License
226 stars 23 forks source link

Slower than Jest #52

Open alecmev opened 2 years ago

alecmev commented 2 years ago

I'm doing image snapshot testing, and it's very slow. The exact same file (no .concurrent) takes ~21 seconds with this runner, and only ~11 seconds with Jest's built-in. It has 58 snapshots, each invoking sharp to rasterize an SVG to PNG and passing it to jest-image-snapshot. Could I be missing something in my setup? I'm using ts-node/esm on top, just in case (and ts-jest for Jest).

nicolo-ribaudo commented 2 years ago

One reason might be that ts-node/esm uses TSC, which is slowed than Babel (which is used by Jest). However, if you only have 58 tests I'm surprised that it has any visible effect.

Also, the performance of jest-image-snapshot should not be affected because it runs "outside" Jest. I don't know where the slowdown may come from :thinking:

liuxingbaoyu commented 2 years ago

Will the test use a lot of memory? May be related to GC, I guess single process may be GC worse than multi process.

mrazauskas commented 7 months ago

I was trying out jest-light-runner hoping for better performance, but it is visibly slower.

In my case it was enough to run a single file with five test cases. A CLI app is being tested, so each test case spawns a process to execute commands with different arguments. Vanilla Jest executes same file in ca. 3.6 and with jest-light-runner it needs almost 4 seconds.

These are rather long running tests similar to the ones described in the OP. A single test case takes ca. 0.7-0.6 seconds to execute. Perhaps that’s what makes the difference so visible?