test_runner: assert entry is a valid object

PR-URL: https://github.com/nodejs/node/pull/55231
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Edigleysson Silva (Edy) 2024-10-06 16:47:00 -03:00 committed by GitHub
parent 90e3e5e173
commit 980b91a1ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -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;

View File

@ -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);
});