36 lines
859 B
TypeScript
36 lines
859 B
TypeScript
/**
|
|
* @viky/configs - Vitest Node Configuration
|
|
* Base Vitest config for Node.js packages
|
|
*/
|
|
import { defineConfig } from 'vitest/config';
|
|
|
|
import type { UserConfig } from 'vitest/config';
|
|
|
|
export function createVitestNodeConfig(options: {
|
|
include?: string[];
|
|
exclude?: string[];
|
|
coverage?: UserConfig['test']['coverage'];
|
|
} = {}): UserConfig {
|
|
const {
|
|
include = ['src/**/*.test.ts', 'src/**/*.spec.ts'],
|
|
exclude = ['node_modules', 'dist'],
|
|
coverage = {},
|
|
} = options;
|
|
|
|
return defineConfig({
|
|
test: {
|
|
globals: true,
|
|
environment: 'node',
|
|
include,
|
|
exclude,
|
|
coverage: {
|
|
provider: 'v8',
|
|
reporter: ['text', 'json', 'html'],
|
|
exclude: ['node_modules/', 'dist/', '**/*.test.ts', '**/*.spec.ts'],
|
|
...coverage,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
export default createVitestNodeConfig();
|