@@ -6,6 +6,7 @@ const { readdirSync } = require('node:fs');
6
6
const { test } = require ( 'node:test' ) ;
7
7
const fixtures = require ( '../common/fixtures' ) ;
8
8
const tmpdir = require ( '../common/tmpdir' ) ;
9
+ const { pathToFileURL } = require ( 'node:url' ) ;
9
10
const skipIfNoInspector = {
10
11
skip : ! process . features . inspector ? 'inspector disabled' : false
11
12
} ;
@@ -320,6 +321,20 @@ test('coverage with source maps', skipIfNoInspector, () => {
320
321
assert . strictEqual ( result . status , 1 ) ;
321
322
} ) ;
322
323
324
+ test ( 'coverage with source maps missing sources' , skipIfNoInspector , ( ) => {
325
+ const file = fixtures . path ( 'test-runner' , 'source-map' , 'missing-sources' , 'index.js' ) ;
326
+ const missing = fixtures . path ( 'test-runner' , 'source-map' , 'missing-sources' , 'nonexistent.js' ) ;
327
+ const result = spawnSync ( process . execPath , [
328
+ '--test' ,
329
+ '--experimental-test-coverage' ,
330
+ file ,
331
+ ] ) ;
332
+
333
+ const error = `Cannot find '${ pathToFileURL ( missing ) } ' imported from the source map for '${ pathToFileURL ( file ) } '` ;
334
+ assert ( result . stdout . toString ( ) . includes ( error ) ) ;
335
+ assert . strictEqual ( result . status , 1 ) ;
336
+ } ) ;
337
+
323
338
test ( 'coverage with ESM hook - source irrelevant' , skipIfNoInspector , ( ) => {
324
339
let report = [
325
340
'# start of coverage report' ,
@@ -487,24 +502,25 @@ test('coverage with included and excluded files', skipIfNoInspector, () => {
487
502
} ) ;
488
503
489
504
test ( 'properly accounts for line endings in source maps' , skipIfNoInspector , ( ) => {
490
- const fixture = fixtures . path ( 'test-runner' , 'source-map- line-lengths' , 'index.js' ) ;
505
+ const fixture = fixtures . path ( 'test-runner' , 'source-map' , ' line-lengths', 'index.js' ) ;
491
506
const args = [
492
507
'--test' , '--experimental-test-coverage' , '--test-reporter' , 'tap' ,
493
508
fixture ,
494
509
] ;
495
510
const report = [
496
511
'# start of coverage report' ,
497
- '# ----------------------------------------------------------------------------' ,
498
- '# file | line % | branch % | funcs % | uncovered lines' ,
499
- '# ----------------------------------------------------------------------------' ,
500
- '# test | | | | ' ,
501
- '# fixtures | | | | ' ,
502
- '# test-runner | | | | ' ,
503
- '# source-map-line-lengths | | | | ' ,
504
- '# index.ts | 100.00 | 100.00 | 100.00 | ' ,
505
- '# ----------------------------------------------------------------------------' ,
506
- '# all files | 100.00 | 100.00 | 100.00 | ' ,
507
- '# ----------------------------------------------------------------------------' ,
512
+ '# ------------------------------------------------------------------' ,
513
+ '# file | line % | branch % | funcs % | uncovered lines' ,
514
+ '# ------------------------------------------------------------------' ,
515
+ '# test | | | | ' ,
516
+ '# fixtures | | | | ' ,
517
+ '# test-runner | | | | ' ,
518
+ '# source-map | | | | ' ,
519
+ '# line-lengths | | | | ' ,
520
+ '# index.ts | 100.00 | 100.00 | 100.00 | ' ,
521
+ '# ------------------------------------------------------------------' ,
522
+ '# all files | 100.00 | 100.00 | 100.00 | ' ,
523
+ '# ------------------------------------------------------------------' ,
508
524
'# end of coverage report' ,
509
525
] . join ( '\n' ) ;
510
526
0 commit comments