-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
--experimental-test-coverage
falsely reports missing coverage where TS source is import type
#54753
Comments
I'm not sure, but maybe inspiration can be taken from istanbuljs/v8-to-istanbul#244 . |
Seems like a bug to me as well. not sure where is the correct place to fix |
Fixes nodejs#54753 Co-Authored-By: Colin Ihrig <[email protected]> Co-Authored-By: Jayden Seric <[email protected]>
(This issue isn't fixed by the linked PR #55037, I've fixed it~sorry for the confusion) |
Hey, I'm thinking this over, and technically the
|
Reopening due to #55339. I've removed
confirmed-bug
IMHO this is expected behavior, as, while annoying, this line is technically not covered. |
Version
v22.8.0
Platform
Subsystem
No response
What steps will reproduce the bug?
With this TypeScript source code in
src/a.mts
(where the import is from doesn't matter):Compiling that to
dist/a.mjs
:With source map
dist/a.mjs.map
:Then in
test.mjs
:Run:
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior? Why is that the expected behavior?
100% code coverage reported for the module
src/a.mts
.What do you see instead?
Notice the false missing line coverage reported in the terminal output:
Additional information
If you comment out the
import type {} from "node:assert";
and rebuild, a second run for functionally the same runtime code now correctly reports no missing coverage:If you don't create source maps when compiling TypeScript modules containing
import type
, the Node.js test runner correctly reports no missing coverage. So the problem is around how Node.js is interpreting the source maps. Only runtime code should determine code coverage; not source code like TypeScriptimport type
that is eliminated in the build.Something else that is strange, is that the Node.js CLI flag
--enable-source-maps
doesn't seem to have an effect on how the Node.js test runner reports coverage; even without the flag it will always take into account the source maps information. Why is coverage exempt from respecting how--enable-source-maps
works for other Node.js features?The text was updated successfully, but these errors were encountered: