vite-jest icon indicating copy to clipboard operation
vite-jest copied to clipboard

First-class Vite integration for Jest

vite-jest

First-class Vite integration for Jest.

Still work-in-progress, here are some working examples:

  • Vue 3 + type: "module" in package.json
  • Vue 3 + type: "commonjs" or no type field in package.json
    • Beware that all source and unit test JavaScript files should be named with the .mjs extension in this case.
  • Vue 3 + TypeScript
  • React + type: "module" in package.json
    • Note that fastRefresh option of @vitejs/plugin-react must be turned off when process.env.NODE_ENV === 'test'
  • React + TypeScript

Usage:

  1. Add preset: 'vite-jest' to your Jest config.
  2. Replace the jest CLI with vite-jest.

See ./packages/vite-jest/README.md for more detailed guidelines and implementation notes.