ixartz/Next-js-Boilerplate

Migrating to Vitest

kaushalyap opened this issue · 8 comments

It seems you recently start working on Playwright migration, which is great!

Next migration is to migrate from Jest to Vitest, since Vitest is reaching 1.0, currently in v1 beta

Why Vitest?

Next.js has a built-in configuration for Jest, which is not the case with Vitest if not wrong?

I can understand we can use Vitest with Vite but Next.js is not build on top of Vite. Love to hear any feedback and suggestion.

What bring Vitest compared to Jest?

https://vitest.dev/guide/comparisons.html#jest

Mainly for performance reasons, faster test suits means faster feedback loop which means improved DX.

There will be official Vite support in Nextjs probably when they reached 1.0

The default configuration provided by Next.js for Jest use @swc/jest behind the scene, should provide a good performance.

Based on some reddit post, Vitest is even slower: https://www.reddit.com/r/reactjs/comments/1066fvv/test_runner_spa_vite_react_vitest_vs_jestswc/?rdt=41518

The default configuration provided by Next.js for Jest use @swc/jest behind the scene, should provide a good performance.

You may be probably right, sorry I did not considered the SWC,

Most recent bench mark without SWC integration shows it is just marginally faster, probably new Turbo pack will improve the test performance more with Jest or bring a testing capabilities like Bun.

So I'll close this issue!

@kaushalyap Thank you for your suggestion, always open to feedback and suggestion.

I would totally reconsider Vitest in the future, very promising.