First-class Vite integration for Jest.
Still work-in-progress, here are some working examples:
- Vue 3 +
type: "module"
inpackage.json
- Vue 3 +
type: "commonjs"
or notype
field inpackage.json
- Beware that all source and unit test JavaScript files should be named with the
.mjs
extension in this case.
- Beware that all source and unit test JavaScript files should be named with the
- Vue 3 + TypeScript
- React +
type: "module"
inpackage.json
- Note that
fastRefresh
option of@vitejs/plugin-react
must be turned off whenprocess.env.NODE_ENV === 'test'
- Note that
- React + TypeScript
Usage:
- Add
preset: 'vite-jest'
to your Jest config. - Replace the
jest
CLI withvite-jest
.
See ./packages/vite-jest/README.md for more detailed guidelines and implementation notes.