mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-21 13:47:39 +02:00
Vitest Pros: * Automated failing test comments on github PRs * A nice local UI with incremental testing when changing files (`yarn test:ui`) * Also nicely supported in all major IDEs, click to run test works (so we won't miss what we had with jest). * Works well with ESM Vitest Cons: * The ESBuild transformer vitest uses takes a little longer to transform than our current SWC/jest setup, however, it is possible to setup SWC as the transformer for vitest as well (though it only does one transform, so we're paying ~7-10 seconds instead of ~ 2-3 seconds in transform phase). * Exposes how slow our tests are (tongue in cheek here)
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { defineConfig, configDefaults } from 'vitest/config';
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
globals: true,
|
|
globalSetup: ['./src/test-setup.ts'],
|
|
setupFiles: ['./src/test/errorWithMessage.ts'],
|
|
reporters: [
|
|
[
|
|
'junit',
|
|
{
|
|
suiteName: 'Unleash Unit Tests',
|
|
outputFile: 'reports/jest-junit.xml',
|
|
classnameTemplate: '{filename} - {filepath}',
|
|
},
|
|
],
|
|
['default'],
|
|
],
|
|
testTimeout: 30000,
|
|
exclude: [
|
|
...configDefaults.exclude,
|
|
'website/**',
|
|
'frontend/**',
|
|
'docker/index.js',
|
|
],
|
|
environment: 'node',
|
|
coverage: {
|
|
reportOnFailure: true,
|
|
reporter: [
|
|
['json', { path: './coverage/coverage-final.json' }],
|
|
['json-summary', { path: './coverage/coverage-summary.json' }],
|
|
['clover'],
|
|
['lcov', { projectRoot: './src' }],
|
|
],
|
|
provider: 'v8',
|
|
exclude: [
|
|
...(configDefaults.coverage.exclude || []),
|
|
'website/**',
|
|
'frontend/**',
|
|
'src/test-setup.ts',
|
|
'src/server-dev.ts',
|
|
'src/server.ts',
|
|
'src/migrator.ts',
|
|
'src/test/**/*.ts',
|
|
'docker/*.js',
|
|
'src/**/fakes/*.ts',
|
|
'scripts',
|
|
],
|
|
reportsDirectory: './coverage',
|
|
},
|
|
silent: 'passed-only',
|
|
},
|
|
});
|