node/test/parallel/test-runner-test-fullname.js
cjihrig 90e81aaad7
test_runner: add context.fullName
This commit adds a fullName getter to the TestContext and
SuiteContext classes. This is similar to the existing name getter,
but also includes the name of all ancestor tests/suites.

PR-URL: https://github.com/nodejs/node/pull/53169
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Co-authored-by: Jacob Smith <jacob@frende.me>
2024-05-30 09:07:17 -04:00

25 lines
548 B
JavaScript

'use strict';
require('../common');
const { strictEqual } = require('node:assert');
const { suite, test } = require('node:test');
suite('suite', (t) => {
strictEqual(t.fullName, 'suite');
test('test', (t) => {
strictEqual(t.fullName, 'suite > test');
t.test('subtest', (t) => {
strictEqual(t.fullName, 'suite > test > subtest');
t.test('subsubtest', (t) => {
strictEqual(t.fullName, 'suite > test > subtest > subsubtest');
});
});
});
});
test((t) => {
strictEqual(t.fullName, '<anonymous>');
});