javascript - liputan ujian vitest tidak gagal apabila ambang tidak dicapai
Saya mahu liputan ujian saya gagal jika ambang tidak dipenuhi
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,
}
},
walaupun saya mendapat mesej ralat, ia masih menunjukkan lulus
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
ada bantuan?
Jawapan #1
Jika anda melihat ini pada tahun 2024 dan menggunakan [email , penyelesaian sebelumnya tidak akan berfungsi untuk anda. thresholds seharusnya menjadi objek sebaliknya.
Lihat kod di bawah:
{
test: {
...your other configurations
coverage: {
...your other configurations
thresholds: {
lines: 80,
functions: 80,
branches: 80,
statements: 80
}
}
}
}
Lihat dokumentasi di sini: coverage.thresholds[glob-pattern]
