{"id":22567,"library":"vite-jest","title":"vite-jest","description":"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.","status":"active","version":"0.1.4","language":"javascript","source_language":"en","source_url":"https://github.com/sodatea/vite-jest","tags":["javascript"],"install":[{"cmd":"npm install vite-jest","lang":"bash","label":"npm"},{"cmd":"yarn add vite-jest","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-jest","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for test runner","package":"jest","optional":false},{"reason":"peer dependency for Vite transform","package":"vite","optional":false}],"imports":[{"note":"Default export. ESM only; CommonJS require not supported.","wrong":"const viteJest = require('vite-jest')","symbol":"viteJest","correct":"import viteJest from 'vite-jest'"},{"note":"Named export. Use to customize transformer options.","wrong":null,"symbol":"createTransformer","correct":"import { createTransformer } from 'vite-jest'"},{"note":"TypeScript type import only, not a runtime value.","wrong":"import { ProjectConfig } from 'vite-jest'","symbol":"ProjectConfig","correct":"import type { ProjectConfig } from 'vite-jest'"}],"quickstart":{"code":"// jest.config.js\nmodule.exports = {\n  testEnvironment: 'node',\n  transform: {\n    '^.+\\.[jt]sx?$': ['vite-jest', { rootDir: __dirname }]\n  }\n};\n\n// sum.ts\nexport const sum = (a: number, b: number) => a + b;\n\n// sum.test.ts\nimport { sum } from './sum';\ntest('adds 1 + 2 to equal 3', () => {\n  expect(sum(1, 2)).toBe(3);\n});","lang":"typescript","description":"Shows base Jest config with vite-jest transformer, a simple TypeScript module, and a corresponding test using Vite's transform."},"warnings":[{"fix":"Upgrade to vite-jest@0.1.4, Jest 27, Vite 2.4.2+.","message":"vite-jest 0.1.x requires Jest 27+ and Vite 2.4.2+. Using older versions causes undefined transform errors.","severity":"breaking","affected_versions":"<0.1.0"},{"fix":"Consider using vitest for production testing.","message":"vite-jest is experimental and may break with Vite or Jest minor updates.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Use ESM import syntax. If Jest config is in CommonJS, use dynamic import: `module.exports = { transform: { '^.+\\.ts$': ['vite-jest', { rootDir: __dirname }] } }`","message":"Using CommonJS require() to import vite-jest throws 'require is not defined' or similar ESM errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Avoid plugins that require server context in tests, or mock them.","message":"When using Vite plugins that rely on server context (e.g., @vitejs/plugin-legacy), tests may fail because there is no dev server.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `npm install -D vite-jest`","cause":"vite-jest not installed or not in node_modules.","error":"Cannot find module 'vite-jest' from 'jest.config.js'"},{"fix":"Make vite.config.ts export a sync object or a sync function.","cause":"Passing an async Vite config to vite-jest; vite-jest expects sync config.","error":"TypeError: Invalid value: Vite config must be a sync function or an object."},{"fix":"Add `rootDir: __dirname` to the transform options in jest.config.js.","cause":"vite-jest cannot determine the project root automatically in some setups.","error":"vite-jest: rootDir option must be specified in Jest config transform block."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}