typescript - מדוע דוח הכיסוי של Vitest מדווח על קובץ שפשוט מייצא אנום?
אנו פועלים לפי מדיניות כיסוי סניפים של 100%. אנו לא עוקבים אחרי פונקציות או שורות. אנו רואים בכך את האיזון הטוב ביותר בין כיסוי קוד לפרודוקטיביות. כרגע יש לנו בעיה שבה vitest מדווח על הקובץ הבא כבעל שני סניפים:
export enum URL {
preSignedUploadUrl = '/case-document/upload/api?fileType=',
saveDocumentUploadToMongoUrl = '/case-document/upload/api?caseReference=',
}
אם אני מוסיף את הבדיקות הבאות, הסניפים מכוסים, אבל כפי שאתה יכול לראות, הם אינם בדיקות יחידה ואינם משרתים מטרה חשובה
import {describe} from 'vitest'
import {URL} from '@config/urls'
describe('urls', () => {
it('has the correct URLs', () => {
expect(URL.preSignedUploadUrl).toEqual(
'/case-document/upload/api?fileType=',
)
expect(URL.saveDocumentUploadToMongoUrl).toEqual(
'/case-document/upload/api?caseReference=',
)
})
})
הגדרות
const config = {
plugins: [react()],
test: {
coverage: {
provider: 'istanbul',
reporter: ['cobertura', 'json', 'html', 'text-summary'],
reportsDirectory: './coverage',
branches: 100,
all: true,
include: ['**/*.ts', '**/*.tsx'],
exclude: ['**/*.spec.ts', '**/*.spec.tsx', '.next/*'],
src: process.cwd() + '/src',
},
setupFiles: './setupTests.js',
exclude: [...configDefaults.exclude, './.next/'],
environment: 'happy-dom',
},
}
export default defineConfig(config)

