@@ -45,6 +45,31 @@ describe('Coverage with source maps', async () => {
45
45
t . assert . strictEqual ( spawned . code , 1 ) ;
46
46
} ) ;
47
47
48
+ it ( 'accounts only mapped lines when --enable-source-maps is provided' , async ( t ) => {
49
+ const report = generateReport ( [
50
+ '# --------------------------------------------------------------' ,
51
+ '# file | line % | branch % | funcs % | uncovered lines' ,
52
+ '# --------------------------------------------------------------' ,
53
+ '# a.test.ts | 100.00 | 100.00 | 100.00 | ' , // part of a bundle
54
+ '# b.test.ts | 88.89 | 100.00 | 100.00 | 1' , // part of a bundle
55
+ '# index.test.js | 71.43 | 66.67 | 100.00 | 6-7' , // no source map
56
+ '# stdin.test.ts | 100.00 | 100.00 | 100.00 | ' , // Source map without original file
57
+ '# --------------------------------------------------------------' ,
58
+ '# all files | 91.67 | 87.50 | 100.00 | ' ,
59
+ '# --------------------------------------------------------------' ,
60
+ ] ) ;
61
+
62
+ const spawned = await common . spawnPromisified ( process . execPath , [
63
+ '--test' , '--experimental-test-coverage' , '--enable-source-maps' , '--test-reporter' , 'tap' ,
64
+ ] , {
65
+ cwd : fixtures . path ( 'test-runner' , 'coverage' )
66
+ } ) ;
67
+
68
+ t . assert . strictEqual ( spawned . stderr , '' ) ;
69
+ t . assert . ok ( spawned . stdout . includes ( report ) ) ;
70
+ t . assert . strictEqual ( spawned . code , 1 ) ;
71
+ } ) ;
72
+
48
73
await it ( 'properly accounts for line endings in source maps' , async ( t ) => {
49
74
const report = generateReport ( [
50
75
'# ------------------------------------------------------------------' ,
@@ -89,6 +114,7 @@ describe('Coverage with source maps', async () => {
89
114
const spawned = await common . spawnPromisified ( process . execPath , [ ...flags , file ] ) ;
90
115
91
116
const error = `The source map for '${ pathToFileURL ( file ) } ' does not exist or is corrupt` ;
117
+
92
118
t . assert . strictEqual ( spawned . stderr , '' ) ;
93
119
t . assert . ok ( spawned . stdout . includes ( error ) ) ;
94
120
t . assert . strictEqual ( spawned . code , 1 ) ;
0 commit comments