i want my test coverage to fail if the thresholds are not met
export default defineConfig({
plugins: [vue()],
test: {
environment: "happy-dom",
exclude: [...configDefaults.exclude, "**/tests/e2e/*"],
coverage: {
reporter: ['text', 'json', 'html'],
lines: 80,
functions: 80,
branches: 80,
statements: 80,
}
},
even though i get the error message, it still shows pass
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
------------------------|---------|----------|---------|---------|-------------------
All files | 100 | 33.33 | 100 | 100 |
components/base/button | 100 | 33.33 | 100 | 100 |
Button.vue | 100 | 33.33 | 100 | 100 | 36-53
config | 100 | 100 | 100 | 100 |
index.ts | 100 | 100 | 100 | 100 |
------------------------|---------|----------|---------|---------|-------------------
ERROR: Coverage for branches (33.33%) does not meet global threshold (80%)
PASS Waiting for file changes...
press h to show help, press q to quit
any help?
CodePudding user response:
You are running tests in watch mode (Waiting for file changes...)
Use this command to run without watch mode: vitest run
Or if you want to run with watch mode ON use: vitest watch