karma-vite
A karma plugin. Transform es module by using vite.
Installation
npm install -D karma karma-vite
Example
Basic
module.exports = (config) => {
config.set({
plugins: ['karma-vite', 'karma-jasmine'],
frameworks: ['vite', 'jasmine'],
files: [
{
pattern: 'test/**/*.spec.ts',
type: 'module',
watched: false,
served: false,
},
],
});
};
full solution
Edit on stackblitz
more examples see in github
Configuration
The plugin works out of the box. But you may need to customize some configuration.
module.exports = (config) => {
config.set({
vite: {
autoInit: true;
config: {
},
coverage: {
},
},
});
};
Typescript Declaration
export interface KarmaViteConfig {
autoInit?: boolean;
config: UserConfigExport;
coverage?: {
enable?: boolean;
include?: string | string[];
exclude?: string | string[];
extension?: string | string[];
cwd?: string;
};
}