Registry / testing / vite-plugin-testem

vite-plugin-testem

JSON →
library1.0.1jsnpmunverified

Vite plugin and Testem middleware helper for running browser tests with Testem. Currently at v1.0.1, released April 2026. Supports Vite 7/8 and Testem 3.20+. Key differentiators: provides both a Vite plugin to inject the Testem client script and a middleware helper to run Vite in middleware mode behind Testem, with automatic shutdown via on_exit hook. No alternative package directly bridges Vite and Testem.

npm install vite-plugin-testem
INSTALL
IMPORT
SIG · VITE-PLUGIN-TESTEM
V
vite-plugin-testem
testingjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

vitePluginTestem
import { vitePluginTestem } from 'vite-plugin-testem'
const vitePluginTestem = require('vite-plugin-testem')
ESM-only; do not use require()
createTestemViteMiddleware
import { createTestemViteMiddleware } from 'vite-plugin-testem'
const { createTestemViteMiddleware } = require('vite-plugin-testem')
ESM-only; CommonJS will fail
createTestemViteMiddleware
const { createTestemViteMiddleware } = await import('vite-plugin-testem')
If using dynamic import in CJS

Configures Vite plugin and Testem middleware for browser unit tests with TAP framework.

// vite.config.js import { defineConfig } from 'vite'; import { vitePluginTestem } from 'vite-plugin-testem'; export default defineConfig({ plugins: [vitePluginTestem({ framework: 'tap' })] }); // testem.js import { createTestemViteMiddleware } from 'vite-plugin-testem'; let close; export default async () => { const { middleware, close: closeFn } = await createTestemViteMiddleware({ root: process.cwd() }); close = closeFn; return { middleware: [middleware], test_page: 'index.html', on_exit(config, data, callback) { close().then(() => callback(null)).catch(callback); } }; };
Debug
Known issues
gotchaMissing on_exit hook leaves Vite watchers alive – process may hang or leave noise.
fix
Call close() from on_exit as shown in README.
affects: >=1.0.0
breakingRequires Vite 7 or 8; incompatible with Vite 5/6.
fix
Upgrade to Vite ^7.0.0 || ^8.0.0.
affects: >=1.0.0
breakingRequires Node >=20.19.0, >=22.12.0 or >=24.0.0. Older Node will fail.
fix
Use a supported Node version.
affects: >=1.0.0
deprecatedNo deprecated symbols; all functions are current.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using require() on ESM-only package
fix
Convert to import statement or use dynamic import
TypeError: middleware is not a function
Forgot to await createTestemViteMiddleware
fix
const { middleware } = await createTestemViteMiddleware(...)
Error: Cannot find module 'testem'
Testem not installed or wrong version
fix
npm install testem@^3.20.0 --save-dev
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
viterequiredPeer dependency – Vite is required to run the plugin
testemoptionalOptional peer – must be installed to run tests
Agent activity
6 hits · last 30 days
node
6
Resources
vite-plugin-testem — npm install vite-plugin-testem · libregistry