Skip to content
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

Erroneous report of missing coverage #253

Closed
sramam opened this issue Sep 23, 2020 · 3 comments
Closed

Erroneous report of missing coverage #253

sramam opened this issue Sep 23, 2020 · 3 comments
Labels

Comments

@sramam
Copy link

sramam commented Sep 23, 2020

c8 report seems to report lack of coverage for "export * from ...`.
This is likely the same as #112. I added a comment there, but noticed the
issue was closed. So filing a new one.

Please see for a simple reproduction.
https://github.com/sramam/c8-empty-lines

My experiments seem to indicate that it only happens for files that export * ....

@sramam
Copy link
Author

sramam commented Sep 23, 2020

Looking at the report of a large (private) repo, it seems this is somehow tied to the EOF marker.
It's always the last line that is reported in the --reporter text report, and always the branch-coverage
that falls short.

@bcoe
Copy link
Owner

bcoe commented Sep 24, 2020

Thank you for providing reproduction @sramam. One thing worth trying, would be turning off source-maps.

It might be the case that TypeScript is actually adding an additional line of code in the built .js, which is legitimately not covered.

@sramam
Copy link
Author

sramam commented Sep 25, 2020

interesting thought.
turns out that the helper functions being emitted by tsc might have been the problem.

Installing tslib seems to resolve this problem.

$ git diff tsconfig.json
diff --git a/tsconfig.json b/tsconfig.json
index b33468a..67a043b 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -10,7 +10,8 @@
       "rootDir": "src",
       "removeComments": false,
       "outDir": "dist",
-      "incremental": true
+      "incremental": true,
+      "importHelpers": true
   },
   "exclude": [
       "node_modules",
$ git diff package.json
diff --git a/package.json b/package.json
index d3274aa..4ffa321 100644
--- a/package.json
+++ b/package.json
@@ -17,5 +17,8 @@
     "c8": "^7.3.1",
     "cross-env": "^7.0.2",
     "typescript": "^4.0.3"
+  },
+  "dependencies": {
+    "tslib": "^2.0.1"
   }
 }
> c8 report -r lcov -r text --report-dir ./.c8-report

(node:20604) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time
-----------|---------|----------|---------|---------|-------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files  |     100 |      100 |     100 |     100 |
 src       |     100 |      100 |     100 |     100 |
  index.ts |     100 |      100 |     100 |     100 |
  main.ts  |     100 |      100 |     100 |     100 |
 src/test  |     100 |      100 |     100 |     100 |
  index.ts |     100 |      100 |     100 |     100 |
-----------|---------|----------|---------|---------|-------------------

@sramam sramam closed this as completed Sep 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants