Registry / testing / cypress-vite

cypress-vite

JSON →
library1.8.0jsnpmunverified

Cypress-vite is a Cypress preprocessor plugin that allows you to compile and run E2E test specs using Vite, the fast JavaScript bundler. Currently at version 1.8.0 (released September 2025), it supports Vite versions 2.9 through 7 and Cypress 10+. Unlike the official @cypress/vite-dev-server (which is for component testing), cypress-vite is designed for E2E testing. It enables reuse of your existing Vite configuration (aliases, plugins, virtual imports, import.meta) in Cypress E2E tests, avoiding the need for a separate webpack configuration. It also offers a prebuild feature to speed up test runs. The package ships TypeScript types.

npm install cypress-vite
INSTALL
IMPORT
SIG · CYPRESS-VITE
C
cypress-vite
testingjavascriptv1.8.0
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default (vitePreprocessor)
import vitePreprocessor from 'cypress-vite'
const vitePreprocessor = require('cypress-vite')
ESM default export. For CommonJS, use `const vitePreprocessor = require('cypress-vite').default` or use dynamic import.
getVitePrebuilder
import { getVitePrebuilder } from 'cypress-vite'
const getVitePrebuilder = require('cypress-vite').getVitePrebuilder
Named export for the prebuild feature. In CommonJS, destructure from require or use `.getVitePrebuilder`.
vitePreprocessor
import vitePreprocessor from 'cypress-vite'
import { vitePreprocessor } from 'cypress-vite'
Default export, not a named export. Using curly braces will result in `undefined`.

Configures Cypress E2E to use Vite for preprocessing test files, allowing Vite-based transforms and faster builds.

// cypress.config.ts import { defineConfig } from 'cypress' import vitePreprocessor from 'cypress-vite' export default defineConfig({ e2e: { setupNodeEvents(on) { on('file:preprocessor', vitePreprocessor()) }, }, })
Debug
Known issues
breakingIn v1.5.0, support for Vite 5 and Cypress 13 was added, dropping older versions. Ensure your Vite version is >=5.0.0.
fix
Upgrade Vite to ^5.0.0 or later. For older Vite versions, stay on v1.4.x.
affects: >=1.5.0
deprecatedThe `configFile` option in vitePreprocessor is deprecated in favor of providing the full Vite config object directly.
fix
Pass a Vite config object to vitePreprocessor({ ... }) instead of using { configFile: 'path' }.
affects: >=1.4.0
gotchaThe prebuild feature (`getVitePrebuilder()`) does not work in watch mode; it is intended for run mode only.
fix
Only use `vitePrebuild` inside `before:run` hook, not in watch mode.
affects: >=1.8.0
gotchaThe plugin overrides `rollupOptions.output.manualChunks` to false. This may conflict with custom Vite configs that set manualChunks.
fix
Avoid setting `manualChunks` in your Vite config or set it to false explicitly.
affects: >=1.4.1
Errors
Common errors & fixes
Error: Cannot find module 'cypress-vite'
Missing dev dependency or incorrect installation.
fix
Run `npm install --save-dev cypress-vite` or `yarn add --dev cypress-vite`.
TypeError: vitePreprocessor is not a function
Importing the default export incorrectly (using named import).
fix
Use `import vitePreprocessor from 'cypress-vite'` (default import) instead of `import { vitePreprocessor } from 'cypress-vite'`.
Error: The 'on' callback is not defined
Missing setupNodeEvents or incorrect Cypress config structure (Cypress 10+).
fix
Ensure your cypress.config.ts has `e2e.setupNodeEvents` defined and the `on` parameter is used.
Upgrade
Version history
1.8.0latest on npm
Audit
Dependencies
viterequiredRuntime peer dependency: Vite is the bundler used to preprocess specs.
Agent activity
35 hits · last 30 days
node
32
Perplexity
1
OpenAI (training)
1
Resources
cypress-vite — npm install cypress-vite · libregistry