I've got an Angular project, while using Cypress as the testing framework. Now I want to get the code coverage using nyc from Istanbul.
I've tried to make a minimal setup of the basic stuff right here: https://github.com/MichaelKoscheck/AngularCypressIstanbul
If I try to run yarn nyc yarn test now, the test file in cypress/e2e gets executed. But the sample spec I defined there tests a simple add method in the app.component.ts file.
However the code coverage summary only includes the main.ts file.
What do I need to do so the app.component.ts gets included in the code coverage report?
I think the problem might be somewhere in the tsconfig.json, but I can't seem to find the solution. Or is this not working in general? If yes, what would I need to do to get to my desired outcome where the app.component.ts gets included into the code coverage report?
My .nycrc file:
{
"all": true,
"per-file": false,
"check-coverage": true,
"lines": 70,
"skip-full": false,
"extension": [".ts"],
"include": "src/**/*.ts",
"reporter": ["html", "text", "lcov", "cobertura"]
}
My tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "ES2022",
"useDefineForClassFields": false,
"lib": [
"ES2022",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}