Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating to Vitest #174

Closed
kaushalyap opened this issue Oct 11, 2023 · 8 comments
Closed

Migrating to Vitest #174

kaushalyap opened this issue Oct 11, 2023 · 8 comments
Labels
question Further information is requested

Comments

@kaushalyap
Copy link

kaushalyap commented Oct 11, 2023

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

@kaushalyap
Copy link
Author

kaushalyap commented Oct 11, 2023

Official Nextjs example code : https://github.com/vercel/next.js/tree/canary/examples/with-vitest

@ixartz
Copy link
Owner

ixartz commented Oct 11, 2023

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?

@ixartz ixartz self-assigned this Oct 11, 2023
@ixartz ixartz added the question Further information is requested label Oct 11, 2023
@ixartz ixartz removed their assignment Oct 11, 2023
@kaushalyap
Copy link
Author

kaushalyap commented Oct 11, 2023

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

@ixartz
Copy link
Owner

ixartz commented Oct 11, 2023

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

@ixartz
Copy link
Owner

ixartz commented Oct 11, 2023

Here is another post about the performance: https://www.jameslmilner.com/posts/speeding-up-typescript-jest-tests/

@kaushalyap
Copy link
Author

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!

@ixartz
Copy link
Owner

ixartz commented Oct 11, 2023

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

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

@ixartz
Copy link
Owner

ixartz commented May 18, 2024

@kaushalyap The project is now using Vitest for testing instead of Jest, thank you so much for the suggestion

#280

Better DX compared to Jest and less configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants