node/test/parallel/test-runner-test-fullname.js
Moshe Atlow cdc577484b test_runner: add passed, attempt, and diagnostic to SuiteContext
PR-URL: https://github.com/nodejs/node/pull/62504
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
2026-04-01 11:29:56 +00:00

48 lines
1.5 KiB
JavaScript

'use strict';
const common = require('../common');
const assert = require('node:assert');
const { before, suite, test } = require('node:test');
before(common.mustCall((t) => {
assert.strictEqual(t.fullName, '<root>');
}));
suite('suite', common.mustCall((t) => {
assert.strictEqual(t.fullName, 'suite');
// Test new SuiteContext properties
assert.strictEqual(typeof t.passed, 'boolean');
assert.strictEqual(t.attempt, 0);
// diagnostic() can be called to add diagnostic output
t.diagnostic('Suite diagnostic message');
test('test', (t) => {
assert.strictEqual(t.fullName, 'suite > test');
t.test('subtest', (t) => {
assert.strictEqual(t.fullName, 'suite > test > subtest');
t.test('subsubtest', (t) => {
assert.strictEqual(t.fullName, 'suite > test > subtest > subsubtest');
});
});
});
}));
test((t) => {
assert.strictEqual(t.fullName, '<anonymous>');
});
// Test SuiteContext passed, attempt, and diagnostic properties
suite('suite with context checks', common.mustCall((ctx) => {
assert.strictEqual(ctx.fullName, 'suite with context checks');
assert.strictEqual(typeof ctx.passed, 'boolean');
assert.strictEqual(ctx.attempt, 0);
// Verify diagnostic method is callable
ctx.diagnostic('Test diagnostic message in suite');
test('child test', () => {
// Verify properties are accessible in nested test
assert.strictEqual(typeof ctx.passed, 'boolean');
assert.strictEqual(ctx.attempt, 0);
});
}));