Why is vitest faster than jest #1635
-
Why is vitest faster than jest, can anyone give me a direction to study or tell me the reason? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
This was what I found in the docs, |
Beta Was this translation helpful? Give feedback.
-
With proper configuration single run of Vitest will be on par with Jest. For me single run of Vitest was faster because I stopped using Babel to process Typescript files. And Vitest is much faster in watch mode as it uses Vite. https://twitter.com/antfu7/status/1468233216939245579 |
Beta Was this translation helpful? Give feedback.
-
However, as far as I know jest is also multi-threaded. So the reason for the performance difference is that jest does not open as many threads as vitest? |
Beta Was this translation helpful? Give feedback.
-
Vite (and therefore Vitest) builds with esbuild which is a native binary compiled with Go. Jest builds with webpack which is a JS package with way more overhead and slower IO. There are other decisions Vite and Vitest make to improvement performance, but this is the main thing separate the new generation of JS tools (Vite, Parcel, esbuild, swc, etc.) from the old generator (webpack, Rollup, etc.) IMO. |
Beta Was this translation helpful? Give feedback.
Vite (and therefore Vitest) builds with esbuild which is a native binary compiled with Go. Jest builds with webpack which is a JS package with way more overhead and slower IO. There are other decisions Vite and Vitest make to improvement performance, but this is the main thing separate the new generation of JS tools (Vite, Parcel, esbuild, swc, etc.) from the old generator (webpack, Rollup, etc.) IMO.