-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for transformers to opt files out of coverage? #5209
Comments
Yes some sort of way to exclude files from coverage would be nice somehow, we've debated several ways to do it on our side, but haven't come up with anything that seemed acceptable. |
@SimenB - Because, for example, in TypeScript projects it is common to have type definition files ( |
Shouldn't empty modules be marked as 100% covered by default anyway? |
coverage is for lines executed, blank lines don't count. You might want to raise an issue with istanbul if you think |
Unfortunately it's not λ npm run test -- --coverage
> ts-jest-wallaby-vscode@2.0.2 test C:\Code\ts-jest-wallaby-vscode
> jest "--coverage"
PASS tests\sum.test.ts
√ adds 1 + 2 to equal 3 (4ms)
----------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
----------|----------|----------|----------|----------|----------------|
All files | 50 | 100 | 100 | 60 | |
sum.ts | 100 | 100 | 100 | 100 | |
types.ts | 0 | 100 | 100 | 0 | 1,2 |
----------|----------|----------|----------|----------|----------------|
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 3.777s
Ran all test suites.
|
If anyone is using TypeScript + TS-Lint, then adding
|
Ah... 🙁 It also has |
You can change that behavior (link). Some projects, including TypeScript itself, enforce the opposite. Also,
|
And do you finally have a simple solution about "Including *.ts and excluding *.d.ts" ? |
If you are using collectCoverageFrom: [
'**/*.[tj]s', // includes js and ts files
'!**/*.d.ts' // excludes .d.ts files
] |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
Death to the stale bot! Jk, this is still relevant. |
I clones the repository in the OP, and just updating all versions to latest shows correct coverage (I guess?). Probably fixed by some source map change at some point through the years
If this is still an issue, please open a new issue with a reproduction using Jest 27 (or jest 28 alpha, but I don't think anything there has changed anything from v27) |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Continuing discussion with @kulshekhar and @GeeWee in kulshekhar/ts-jest#378.
In TypeScript, it's not uncommon to have files with no output JS code, just interface/type definitions:
These end up being counted as 2/2 uncovered lines in the file because the file does get compiled into a .js equivalent:
Here's a min repro: https://github.com/JoshuaKGoldberg/ts-jest-wallaby-vscode/tree/ts-jest-coverage-repro
The simplest approach I can think of would be to allow ts-jest to mark the file as excluded from code coverage.
The text was updated successfully, but these errors were encountered: