A Karma plugin that uses Vite to transform ES modules for testing. Current stable version is 1.0.5, released December 2023, supporting Vite 2 through 5. It enables using Vite's fast development server and module transformation within Karma test runner. Unlike karma-webpack or karma-rollup, it leverages Vite's on-demand compilation and HMR-like middleware for quicker test re-runs. Requires Karma 6+ and Vite 2-5 as peer dependencies. Ships TypeScript types.
npm install karma-viteVerified import paths — ran on the pinned version, not inferred.
Minimal Karma configuration to run Jasmine tests with Vite transformation. Tests are ES modules with .ts extension, and Vite handles TypeScript compilation.
Set type: 'module', watched: false, served: false on all test file entries.
Upgrade to 1.0.1 or later. Alternatively, set urlRoot to a non-root path (e.g., '/karma/').
Use Vite 3, 4, or 5 with karma-vite >=1.0.5.
Upgrade to 1.0.3 or later.
Upgrade to 1.0.1 or later.
Ensure karma-coverage plugin is installed and add 'coverage' to reporters array in Karma config.
Set urlRoot to a non-root path (e.g., '/karma/') in karma.conf.js, or upgrade to karma-vite v1.0.1+.
Run 'npm install -D karma-vite'. Ensure 'karma-vite' is listed in the plugins array (not require()'d directly).
Upgrade to karma-vite v1.0.3 or later.
Upgrade to karma-vite v1.0.1 or later.