Skip to content

test_runner: fix TypeError exception when --enable-source-maps is passed #55231

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
@@ -560,7 +560,7 @@ class Test extends AsyncResource {
const map = lazyFindSourceMap(this.loc.file);
const entry = map?.findEntry(this.loc.line - 1, this.loc.column - 1);

if (entry !== undefined) {
if (entry?.originalSource !== undefined) {
this.loc.line = entry.originalLine + 1;
this.loc.column = entry.originalColumn + 1;
this.loc.file = entry.originalSource;
16 changes: 16 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,16 @@
'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');

test('ensures --enable-source-maps does not throw an error', () => {
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);
});