v8 coverage crashes with type-only files
See original GitHub issue🐛 Bug Report
With coverageProvider: 'v8'
and coverage enabled, Jest crashes with imported but non-elided type-only modules.
To Reproduce
Steps to reproduce the behavior:
jest.config.mjs
:export default { collectCoverage: true, coverageProvider: 'v8', rootDir: 'src' };
babel.config.json
{ "presets": [ "@babel/typescript" ] }
src/types.ts
:export interface obj {}
src/mytest.test.ts
:import * as types from './types'; test('1+1=2', () => { console.log(types); expect(1 + 1).toBe(2); });
- Run
npx jest
PASS src2/mytest.test.ts √ 1+1=2 (16 ms) console.log { default: {} } at Object.<anonymous> (mytest.test.ts:4:11) TypeError: Cannot read property 'replace' of undefined at V8ToIstanbul._resolveSource (D:\repo\node_modules\v8-to-istanbul\lib\v8-to-istanbul.js:86:29) at V8ToIstanbul.load (D:\repo\node_modules\v8-to-istanbul\lib\v8-to-istanbul.js:57:26) at D:\repo\node_modules\@jest\reporters\build\CoverageReporter.js:624:27 at Array.map (<anonymous>) at CoverageReporter._getCoverageResult (D:\repo\node_modules\@jest\reporters\build\CoverageReporter.js:587:32) at CoverageReporter.onRunComplete (D:\repo\node_modules\@jest\reporters\build\CoverageReporter.js:231:45) at ReporterDispatcher.onRunComplete (D:\repo\node_modules\@jest\core\build\ReporterDispatcher.js:88:9) at TestScheduler.scheduleTests (D:\repo\node_modules\@jest\core\build\TestScheduler.js:350:5) at runJest (D:\repo\node_modules\@jest\core\build\runJest.js:376:19) at _run10000 (D:\repo\node_modules\@jest\core\build\cli\index.js:416:7)
Expected behavior
Jest doesn’t crash, and coverage works.
Link to repl or repo (highly encouraged)
envinfo
System:
OS: Windows 10 10.0.19042
CPU: (64) x64 AMD Ryzen Threadripper 3970X 32-Core Processor
Binaries:
Node: 15.2.0 - C:\Program Files\nodejs\node.EXE
npm: 7.0.8 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^26.6.3 => 26.6.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:14 (1 by maintainers)
Top Results From Across the Web
The hunt for chromium issue 1072171 - SensePost
The last few months I've been studying Chrome's v8 internals and exploits with the focus of finding a type confusion bug.
Read more >Code Coverage in Chromium
The code coverage CQ builders instrument only the files changed for a given CL. ... If a crash of any type occurs (e.g....
Read more >Visual Studio 2019 crashes when 'Show code coverage ...
Several times a day I experience that Visual Studio 2019 crashes when I want to see my code coverage. It happens when clicking...
Read more >Average Car Insurance Costs for 21-Year Old Drivers
The average cost of auto insurance for a 21-year-old is $384 per month, ... tend to get into more accidents and file more...
Read more >V.A.C.® Therapy Insurance Authorization Form (v8.0)
V.A.C.® Therapy Insurance Authorization Form (v8.0). Please fax this form to 3M-KCI ... I prescribe 3M-KCI V.A.C.® Therapy for the following wound type(s):....
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
Just merged @viceice’s patch 👌 sorry for the nuisance.
This is what we pass
Seems like a bug in
v8-to-istanbul
to me. We pass a valid sourcemap - it’s just empty