HTML reporter reports 'Unable to lookup source'
See original GitHub issueLink to bug demonstration repository
🍫☕️
Expected behavior
I attempted to follow the installation instructions at istanbul.js.org. I expect the HTML report generated by nyc mocha to have working links to view the coverage of each source file.
Observed behavior
Unable to lookup source: /Users/jackson/Documents/mocha/src/file:/Users/jackson/Documents/mocha/src/hello.ts (ENOENT: no such file or directory, open '/Users/jackson/Documents/mocha/src/file:/Users/jackson/Documents/mocha/src/hello.ts')
Error: Unable to lookup source: /Users/jackson/Documents/mocha/src/file:/Users/jackson/Documents/mocha/src/hello.ts (ENOENT: no such file or directory, open '/Users/jackson/Documents/mocha/src/file:/Users/jackson/Documents/mocha/src/hello.ts')
at Context.defaultSourceLookup [as sourceFinder] (/Users/jackson/Documents/mocha/node_modules/istanbul-lib-report/lib/context.js:17:15)
at Context.getSource (/Users/jackson/Documents/mocha/node_modules/istanbul-lib-report/lib/context.js:71:21)
at annotateSourceCode (/Users/jackson/Documents/mocha/node_modules/istanbul-reports/lib/html/annotator.js:232:40)
at HtmlReport.onDetail (/Users/jackson/Documents/mocha/node_modules/istanbul-reports/lib/html/index.js:414:33)
at Visitor.value (/Users/jackson/Documents/mocha/node_modules/istanbul-lib-report/lib/tree.js:38:38)
at ReportNode.visit (/Users/jackson/Documents/mocha/node_modules/istanbul-lib-report/lib/tree.js:88:21)
at /Users/jackson/Documents/mocha/node_modules/istanbul-lib-report/lib/tree.js:92:19
at Array.forEach ()
at ReportNode.visit (/Users/jackson/Documents/mocha/node_modules/istanbul-lib-report/lib/tree.js:91:28)
at ReportTree.visit (/Users/jackson/Documents/mocha/node_modules/istanbul-lib-report/lib/tree.js:127:24)
Troubleshooting steps
- Similar to the behavior described in this issue from 2017.
- The call to
remapCoverage(map.data)innycseems to be clobbering the paths in the source map.
Environment information
System:
OS: macOS 12.4
CPU: (8) arm64 Apple M1
Memory: 272.58 MB / 16.00 GB
Binaries:
Node: 18.4.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.12.1 - /opt/homebrew/bin/npm
npmPackages:
nyc: ^15.1.0 => 15.1.0
source-map-support: ^0.5.21 => 0.5.21
ts-node: ^10.8.1 => 10.8.1
typescript: ^4.7.4 => 4.7.4
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
nyc says "Unable to lookup source" in reports
I am generating coverage reports using nyc in Node 16. Unable to lookup source: /home/<user>/code/<project>/src/rest/file:/home/<user>/code/< ...
Read more >Embed a report - Looker Studio Help
Edit the HTML source of the page in which you want to embed the report. Paste the iframe code where you want the...
Read more >Unable to upload the sonar coverage report for angular ...
6 11:20:40.999 INFO: Default locale: "en", source code encoding: "UTF-8" 11:20:41.000 DEBUG: Work directory: /home/jenkins/workspace/_ci-webapp- ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I was having the same issue. Downgrading to ts-node: 10.8.0 resolved it for me. Hope it helps.
@coreyfarrell @bcoe There’s an ongoing discussion about this problem on ts-node’s side: https://github.com/TypeStrong/ts-node/issues/1790
According to them, it might as well be a bug on nyc’s side.