Skip to content

Commit

Permalink
test: move --enable-source-maps test to a single file
Browse files Browse the repository at this point in the history
  • Loading branch information
geeksilva97 committed Oct 2, 2024
1 parent f5c4c40 commit 176b447
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 37 deletions.
37 changes: 0 additions & 37 deletions test/parallel/test-runner-coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,43 +321,6 @@ test('coverage with source maps', skipIfNoInspector, () => {
assert.strictEqual(result.status, 1);
});


test('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,
];

let 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');

if (common.isWindows) {
report = report.replaceAll('/', '\\');
}

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
19 changes: 19 additions & 0 deletions test/parallel/test-runner-enable-source-maps-issue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';
require('../common');
const assert = require('node:assert');
const { spawnSync } = require('node:child_process');
const { test } = require('node:test');
const fixtures = require('../common/fixtures');
const skipIfNoInspector = {
skip: !process.features.inspector ? 'inspector disabled' : false
};

test('ensures --enable-source-maps does not throw an error', skipIfNoInspector, () => {
const fixture = fixtures.path('test-runner', 'coverage', 'stdin.test.js');
const args = ['--enable-source-maps', fixture];

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

assert.strictEqual(result.stderr.toString(), '');
assert.strictEqual(result.status, 0);
});

0 comments on commit 176b447

Please sign in to comment.