Skip to content

Commit

Permalink
test: test case when --enable-source-maps is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksilva97 committed Oct 2, 2024
1 parent 38126ee commit 3cf0246
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/parallel/test-runner-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,39 @@ test('coverage with source maps', skipIfNoInspector, () => {
assert.strictEqual(result.status, 1);
});


test.only('coverage with --enable-source-maps option', skipIfNoInspector, () => {
const fixture = fixtures.path('test-runner', 'coverage', 'stdin.test.js');
const args = [
'--test', '--experimental-test-coverage', '--enable-source-maps', '--test-reporter', 'tap',
fixture,
];

const report = [
'# start of coverage report',
'# ------------------------------------------------------------------',
'# file | line % | branch % | funcs % | uncovered lines',
'# ------------------------------------------------------------------',
'# test | | | | ',
'# fixtures | | | | ',
'# test-runner | | | | ',
'# coverage | | | | ',
'# stdin.test.ts | 57.14 | 100.00 | 100.00 | 4-6',
'# ------------------------------------------------------------------',
'# all files | 57.14 | 100.00 | 100.00 | ',
'# ------------------------------------------------------------------',
'# end of coverage report'
].join('\n');

const result = spawnSync(process.execPath, args);
const stdOut = result.stdout.toString();

assert.strictEqual(result.stderr.toString(), '');
assert(!stdOut.includes('TypeError'));
assert(stdOut.includes(report));
assert.strictEqual(result.status, 0);
});

test('coverage with source maps missing sources', skipIfNoInspector, () => {
const file = fixtures.path('test-runner', 'source-map-missing-sources', 'index.js');
const missing = fixtures.path('test-runner', 'source-map-missing-sources', 'nonexistent.js');
Expand Down

0 comments on commit 3cf0246

Please sign in to comment.