I was looking at testing H5WasmApi but ran into hair-pulling issues with Jest and its lack of stable support for ESM (h5wasm doesn't publish a CommonJS bundle ... and it shouldn't have to these days!) I did an initial foray into testing it with Vitest and it worked perfectly, so I decided to try the full migration from Jest to Vitest once again.
I'm happy to report that I've managed to successfully complete the migration this time around. There were a few tricky bits due to the fact that Testing Library was designed for Jest and does not yet fully support Vitest, but I was able to work around them.
And the result is great:
Vitest supports ESM, so it doesn't need to transform modules to CommonJS like Jest. As a result, the tests run 20s faster in the CI (from 1:40 to 1:20).
Vitest uses the projects' existing Vite configuration to know how to process the files (JSX, TypeScript, etc.) so there's pretty much nothing to configure (unlike with Jest, which required ts-jest for TS support, identity-object-proxy to ignore CSS imports, etc.)!
Vitest provides a nice little UI to run the tests, which looks quite neat (see below).
Apart from that, the testing API is pretty much the same (mocks, fake timers, etc.) This is also thanks to the fact that jest-dom supports Vitest.
I was looking at testing
H5WasmApi
but ran into hair-pulling issues with Jest and its lack of stable support for ESM (h5wasm
doesn't publish a CommonJS bundle ... and it shouldn't have to these days!) I did an initial foray into testing it with Vitest and it worked perfectly, so I decided to try the full migration from Jest to Vitest once again.I'm happy to report that I've managed to successfully complete the migration this time around. There were a few tricky bits due to the fact that Testing Library was designed for Jest and does not yet fully support Vitest, but I was able to work around them.
And the result is great:
ts-jest
for TS support,identity-object-proxy
to ignore CSS imports, etc.)!jest-dom
supports Vitest.