-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-runner-subtest-skip-todo-only.js
More file actions
46 lines (39 loc) · 1.53 KB
/
test-runner-subtest-skip-todo-only.js
File metadata and controls
46 lines (39 loc) · 1.53 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
'use strict';
require('../common');
const assert = require('node:assert');
const { test } = require('node:test');
const { isPromise } = require('node:util/types');
// Regression test for https://github.com/nodejs/node/issues/50665
// Ensures that t.test.skip, t.test.todo, and t.test.only are available
// on the subtest context.
test('subtest context should have test variants', async (t) => {
assert.strictEqual(typeof t.test, 'function');
assert.strictEqual(typeof t.test.skip, 'function');
assert.strictEqual(typeof t.test.todo, 'function');
assert.strictEqual(typeof t.test.only, 'function');
});
test('subtest variants should return promises', async (t) => {
const normal = t.test('normal subtest');
const skipped = t.test.skip('skipped subtest');
const todo = t.test.todo('todo subtest');
assert(isPromise(normal));
assert(isPromise(skipped));
assert(isPromise(todo));
await normal;
await skipped;
await todo;
});
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.skip, 'function');
assert.strictEqual(typeof t.test.todo, 'function');
assert.strictEqual(typeof t.test.only, 'function');
await t.test('level 2', async (t) => {
assert.strictEqual(typeof t.test, 'function');
assert.strictEqual(typeof t.test.skip, 'function');
assert.strictEqual(typeof t.test.todo, 'function');
assert.strictEqual(typeof t.test.only, 'function');
});
});
});