-
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
Bad error message in --experimental-test-coverage
output when a source maps source module is missing
#54756
Comments
See also #54444, which resolved a similar error, so maybe they are somewhat related? |
If someone wants to pick this up, this diff plus the test case provided in the bug report should get you started: diff --git a/lib/internal/test_runner/coverage.js b/lib/internal/test_runner/coverage.js
index 7ef5702072..4348ea06c3 100644
--- a/lib/internal/test_runner/coverage.js
+++ b/lib/internal/test_runner/coverage.js
@@ -388,8 +388,12 @@ class TestCoverage {
continue;
}
- newUrl ??= startEntry?.originalSource;
- const mappedLines = this.getLines(newUrl);
+ const mappedLines = this.getLines(startEntry.originalSource);
+ if (!mappedLines) {
+ throw new Error('insert better error message here');
+ }
+
+ newUrl ??= startEntry.originalSource;
const mappedStartOffset = this.entryToOffset(startEntry, mappedLines);
const mappedEndOffset = this.entryToOffset(endEntry, mappedLines) + 1;
for (let l = startEntry.originalLine; l <= endEntry.originalLine; l++) { |
What even is the issue? Is it:
|
In that snippet, |
Working on this now. |
Fixes nodejs#54756 Co-Authored-By: Colin Ihrig <[email protected]> Co-Authored-By: Jayden Seric <[email protected]>
Version
v22.8.0
Platform
Subsystem
No response
What steps will reproduce the bug?
In
dist/a.mjs
:In
dist/a.mjs.map
:In
test.mjs
:Then, run:
How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior? Why is that the expected behavior?
An error message reported after the tests output, explaining that a particular source module at a path is missing. If multiple are missing, then output the list of missing paths.
What do you see instead?
Additional information
This scenario comes up very frequently when working in a TypeScript project with source maps enabled, that has
src
anddist
directories. Often you have a build script watching thesrc
directory, and as you work you rename or delete a source module. The result is that old artifacts don't get cleaned in thedist
directory, but the next time the tests run on thedist
directory the coverage explodes with the error this issue reports.Note that if multiple test modules run, then the coverage report for everything is obscured by the error message:
The text was updated successfully, but these errors were encountered: