javascript - la cobertura de pruebas de vitest no falla cuando no se cumple el umbral
quiero que la cobertura de mis pruebas falle si no se cumplen los umbrales
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,
}
},
aunque reciba el mensaje de error, todavía muestra aprobado
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
¿alguna ayuda?
Respuesta #1
Si estás viendo esto en 2024 y usando [email , la solución anterior no funcionará para ti. thresholds debería ser un objeto en su lugar.
Consulta el código a continuación:
{
test: {
...your other configurations
coverage: {
...your other configurations
thresholds: {
lines: 80,
functions: 80,
branches: 80,
statements: 80
}
}
}
}
Consulta la documentación aquí: coverage.thresholds[glob-pattern]
