Skip to content

Commit 065381a

Browse files
committed
test: coverage report with --enable-source-maps
1 parent 67517de commit 065381a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/parallel/test-runner-coverage-source-map.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,31 @@ describe('Coverage with source maps', async () => {
4545
t.assert.strictEqual(spawned.code, 1);
4646
});
4747

48+
await it.only('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 | 85.71 | 100.00 | 0.00 | 2', // Source map without original file
57+
'# --------------------------------------------------------------',
58+
'# all files | 88.89 | 85.71 | 66.67 | ',
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+
4873
await it('properly accounts for line endings in source maps', async (t) => {
4974
const report = generateReport([
5075
'# ------------------------------------------------------------------',

0 commit comments

Comments
 (0)