I recently started using Vitest and encountered an issue: Vitest displays an error indicating that the coverage requirements are not met, but it still shows a PASS status for the tests.
My vitest config looks like:
import path from 'path'
import { coverageConfigDefaults, defineConfig } from 'vitest/config'
export default defineConfig({
test: {
alias: { '@': path.resolve(__dirname, 'src') },
outputFile: 'test_result/junit.xml',
globals: true,
environment: 'jsdom',
setupFiles: 'vitest-setup.ts',
include: ['./src/tests/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
css: {
include: [/.+/],
},
passWithNoTests:false,
coverage: {
all:true,
exclude: [...coverageConfigDefaults.exclude],
include: ['src/**/*', '!src/tests/**'],
enabled: true,
reporter: ['text', 'json', 'html'],
thresholds: {
functions: 20,
branches: 20,
statements: 20,
lines: 20,
},
},
},
})
The command I run is:
"test": "vitest -- --coverage --watchAll=false || exit 0"
Is this some issue with vitest or I missed something in my configuration
Thanks