Skip to content

Commit 0a05d06

Browse files
Renegade334richardlau
authored andcommitted
test_runner: do not error when getting fullName of root context
PR-URL: #59377 Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent c690b53 commit 0a05d06

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/internal/test_runner/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,8 @@ class Suite extends Test {
14591459
}
14601460

14611461
function getFullName(test) {
1462+
if (test === test.root) return test.name;
1463+
14621464
let fullName = test.name;
14631465

14641466
for (let t = test.parent; t !== t.root; t = t.parent) {

test/parallel/test-runner-test-fullname.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
'use strict';
22
require('../common');
33
const { strictEqual } = require('node:assert');
4-
const { suite, test } = require('node:test');
4+
const { before, suite, test } = require('node:test');
5+
6+
before((t) => {
7+
strictEqual(t.fullName, '<root>');
8+
});
59

610
suite('suite', (t) => {
711
strictEqual(t.fullName, 'suite');

0 commit comments

Comments
 (0)