-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-runner-subtest-methods.js
More file actions
53 lines (47 loc) · 1.75 KB
/
test-runner-subtest-methods.js
File metadata and controls
53 lines (47 loc) · 1.75 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
49
50
51
52
53
'use strict';
require('../common');
const assert = require('node:assert');
const { test } = require('node:test');
const { isPromise } = require('node:util/types');
test('subtest context should have test variants', async (t) => {
assert.strictEqual(typeof t.test, 'function');
assert.strictEqual(typeof t.test.expectFailure, 'function');
assert.strictEqual(typeof t.test.only, 'function');
assert.strictEqual(typeof t.test.skip, 'function');
assert.strictEqual(typeof t.test.todo, 'function');
});
test('subtest should return a promise', async (t) => {
const normal = t.test('normal subtest');
assert.ok(isPromise(normal));
await normal;
});
test('t.test[variant]() should return a promise', async (t) => {
assert.ok(isPromise(
t.test.expectFailure('expectFailure subtest', () => { throw new Error('This should pass'); })
));
assert.ok(isPromise(
t.test.only('only subtest')
));
assert.ok(isPromise(
t.test.skip('skip subtest')
));
assert.ok(isPromise(
t.test.todo('todo subtest')
));
});
test('nested subtests should have test variants', async (t) => {
await t.test('level 1', async (t) => {
assert.strictEqual(typeof t.test, 'function');
assert.strictEqual(typeof t.test.expectFailure, 'function');
assert.strictEqual(typeof t.test.only, 'function');
assert.strictEqual(typeof t.test.skip, 'function');
assert.strictEqual(typeof t.test.todo, 'function');
await t.test('level 2', async (t) => {
assert.strictEqual(typeof t.test, 'function');
assert.strictEqual(typeof t.test.expectFailure, 'function');
assert.strictEqual(typeof t.test.skip, 'function');
assert.strictEqual(typeof t.test.todo, 'function');
assert.strictEqual(typeof t.test.only, 'function');
});
});
});