In this post join me as I migrate my project’s test runner framework from Jest to Vitest, and check if it is really as they claim - “A blazing fast...
For further actions, you may consider blocking this person and/or reporting abuse
My friends, family and colleagues told me I shouldn't run off after another test framework, but now I know we're right and they're wrong. Thanks for this article!
I've been using vitest because of remix stacks. Almost everything feels the same as jest but I notice a few things pragmatically.
Pros
Cons
.only
and.skip
don't seem to work as well for mejest setup has been stressing me out all day, I'm happy that at I came across vitest today and then this article helped me solve the document is not defined issue that i ran into when using vitest. Thanks for writing
Glad I could help 🍻
Love this ❤️
Thanks!
Thank you for this post!
Can I use vitest for company new project now?
I believe you can, but make sure it answers all your company's needs
You showed how to define
setupFiles
in vite.config, but you did not reference the contents ofsetupTests.js
.Could you include what should be in there for the Chai issue to resolve?
Vitest is not that fast as it pretends to be. Jest is faster in most cases, because usually you expect isolation in tests, but Vitest has problems with performance. Here is a Github issue github.com/vitest-dev/vitest/issue....
I’m definitely keeping my eyes on vitest and this post makes me wanna give it another shot (forget exactly why but had trouble getting it working a few weeks back) but the whole philosophy of vitest is really compelling. Thanks for the nice case study!
With pleasure :)
Oh, that looked surprisingly simple!
I am still a bit unsure how enzyme would fit into the Vitest environment and how easy it is to setup with next.js - but the Vitest project sounds SO promising!
It is suggested to drop enzyme tests, because it is not supported any more. Keeping aside that it brings questionable value.
Thanks Emil. I have also come to that conclusion myself 🙂
Remix Vite plugin can't detect preamble. Something is wrong.
❯ app/routes/stored.tsx:2:8
1| export default function Comp(){
2| return <h1>jcs</h1>
Error: Remix Vite plugin can't detect preamble. Something is wrong.
here is my vite.config
///
///
import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
installGlobals();
export default defineConfig({
test:{
environment:"jsdom",
globals: true,
setupFiles: ["./set-up-test.env.ts"],
},
plugins: [
remix({
ignoredRouteFiles: ["*/.css"],
}),
tsconfigPaths(),
],
});
can you help me solve this
I hope vitest gets more traction and becomes a solid alternative to jest for vue and svelte also soon. thanks for the write-up
Thank you for this post, just like a "TL,DR" for me to migrate to vitest.
Cheers :) Just remember that this is not production ready yet, according to their readme.
Hard to tell how much improvement there is, since we don't know how many & how complicated the tests are.
I mean he literally said it was 4 test files, and 37 tests. A small sample size, sure, but large enough to show relative progress.
I'd love to see some numbers for larger codebases, but that's tough since the software is still considered not production ready.
True. I won't use my little PoC here to determine whether or not you should use Vitest, but I do say it does look promising.
Great post!
as always, love to read your articles!
their comment on not being ready for production and the tight coupling to vite will cause me to wait some more :)
Cheers :)
Yeah, I'd wait for it some a little bit more