-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-runner-test-fullname.js
More file actions
48 lines (40 loc) · 1.45 KB
/
test-runner-test-fullname.js
File metadata and controls
48 lines (40 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'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);
});
}));