Skip to content

Commit e964c43

Browse files
Renegade334targos
authored andcommitted
test_runner: do not error when getting fullName of root context
PR-URL: #59377 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 18a2ee5 commit e964c43

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
@@ -1533,6 +1533,8 @@ class Suite extends Test {
15331533
}
15341534

15351535
function getFullName(test) {
1536+
if (test === test.root) return test.name;
1537+
15361538
let fullName = test.name;
15371539

15381540
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)