◐ Shell
clean mode source ↗

test_runner: do not error when getting `fullName` of root context · nodejs/node@e964c43

Commit e964c43

Renegade334targos

authored and

committed

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>

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

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

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