Registry / testing / vite-jest

vite-jest

JSON →
library0.1.4jsnpmunverified

A Jest transformer for seamless Vite integration in testing, version 0.1.4. Provides Vite's transform pipeline for Jest, allowing use of Vite plugins and TypeScript without separate config. Lightweight alternative to ts-jest when using Vite. Active development but experimental.

npm install vite-jest
INSTALL
IMPORT
SIG · VITE-JEST
V
vite-jest
testingjavascriptv0.1.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

viteJest
import viteJest from 'vite-jest'
const viteJest = require('vite-jest')
Default export. ESM only; CommonJS require not supported.
createTransformer
import { createTransformer } from 'vite-jest'
Named export. Use to customize transformer options.
ProjectConfig
import type { ProjectConfig } from 'vite-jest'
import { ProjectConfig } from 'vite-jest'
TypeScript type import only, not a runtime value.

Shows base Jest config with vite-jest transformer, a simple TypeScript module, and a corresponding test using Vite's transform.

// jest.config.js module.exports = { testEnvironment: 'node', transform: { '^.+\.[jt]sx?$': ['vite-jest', { rootDir: __dirname }] } }; // sum.ts export const sum = (a: number, b: number) => a + b; // sum.test.ts import { sum } from './sum'; test('adds 1 + 2 to equal 3', () => { expect(sum(1, 2)).toBe(3); });
Debug
Known issues
breakingvite-jest 0.1.x requires Jest 27+ and Vite 2.4.2+. Using older versions causes undefined transform errors.
fix
Upgrade to vite-jest@0.1.4, Jest 27, Vite 2.4.2+.
affects: <0.1.0
deprecatedvite-jest is experimental and may break with Vite or Jest minor updates.
fix
Consider using vitest for production testing.
affects: >=0.0.0
gotchaUsing CommonJS require() to import vite-jest throws 'require is not defined' or similar ESM errors.
fix
Use ESM import syntax. If Jest config is in CommonJS, use dynamic import: `module.exports = { transform: { '^.+\.ts$': ['vite-jest', { rootDir: __dirname }] } }`
affects: >=0.1.0
gotchaWhen using Vite plugins that rely on server context (e.g., @vitejs/plugin-legacy), tests may fail because there is no dev server.
fix
Avoid plugins that require server context in tests, or mock them.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'vite-jest' from 'jest.config.js'
vite-jest not installed or not in node_modules.
fix
Run `npm install -D vite-jest`
TypeError: Invalid value: Vite config must be a sync function or an object.
Passing an async Vite config to vite-jest; vite-jest expects sync config.
fix
Make vite.config.ts export a sync object or a sync function.
vite-jest: rootDir option must be specified in Jest config transform block.
vite-jest cannot determine the project root automatically in some setups.
fix
Add `rootDir: __dirname` to the transform options in jest.config.js.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies
jestrequiredpeer dependency for test runner
viterequiredpeer dependency for Vite transform
Agent activity
10 hits · last 30 days
node
10
Resources
vite-jest — npm install vite-jest · libregistry