Vi(olently fast)test 06/03/2022
devtesting

I had to start up a new Vue 3 environment for a technical test recently. I opted to go down the route of using Vite & Vitest with it, I needed to feel the speed they offer.

A lot of people have mentioned having issues migrating from Jest to Vitest and it’s understandable, there is a little more configuration to get it matching what Jest can do.

For example, the auto-inclusion of globals like describe and expect is under a config option and the idea is you can import the required methods instead, with the effect of not having to load everything into every test run.

However, if you’re starting fresh and you’re ready for the slight gotchas that differ then it’s a breezy and speedy process.

In terms of compatibility, it works flawlessly with anything I use it for. I shouldn’t be expecting different but the swap from Vue 2 to Vue 3 was a reasonable shift in mental and component structure so figured it may be impacted here as well.

Pleasantly, it all went great.

I included everything I needed to get my tests running, I pulled in MSW (check here for my little write up on that) and went flying.

I haven’t done a proper speed comparison but in this small example, when I had it running in watch mode it seemed to tear through any changes I was making.

So, from my point of view you should give it a shot. There’s not a lot to talk about in reality. It works identically to Jest, you can see the official comparison here. There are just a few caveats around it which you will easily get used to.

Go forth testing battalion! Update and revel in the speed!