|
1 |
| -// Flags: --no-warnings --test-only |
| 1 | +// Flags: --no-warnings |
2 | 2 | 'use strict';
|
3 |
| -require('../../../common'); |
| 3 | +const common = require('../../../common'); |
4 | 4 | const { test, describe, it } = require('node:test');
|
5 | 5 |
|
6 | 6 | // These tests should be skipped based on the 'only' option.
|
7 |
| -test('only = undefined'); |
8 |
| -test('only = undefined, skip = string', { skip: 'skip message' }); |
9 |
| -test('only = undefined, skip = true', { skip: true }); |
10 |
| -test('only = undefined, skip = false', { skip: false }); |
11 |
| -test('only = false', { only: false }); |
12 |
| -test('only = false, skip = string', { only: false, skip: 'skip message' }); |
13 |
| -test('only = false, skip = true', { only: false, skip: true }); |
14 |
| -test('only = false, skip = false', { only: false, skip: false }); |
| 7 | +test('only = undefined', common.mustNotCall()); |
| 8 | +test('only = undefined, skip = string', { skip: 'skip message' }, common.mustNotCall()); |
| 9 | +test('only = undefined, skip = true', { skip: true }, common.mustNotCall()); |
| 10 | +test('only = undefined, skip = false', { skip: false }, common.mustNotCall()); |
| 11 | +test('only = false', { only: false }, common.mustNotCall()); |
| 12 | +test('only = false, skip = string', { only: false, skip: 'skip message' }, common.mustNotCall()); |
| 13 | +test('only = false, skip = true', { only: false, skip: true }, common.mustNotCall()); |
| 14 | +test('only = false, skip = false', { only: false, skip: false }, common.mustNotCall()); |
15 | 15 |
|
16 | 16 | // These tests should be skipped based on the 'skip' option.
|
17 |
| -test('only = true, skip = string', { only: true, skip: 'skip message' }); |
18 |
| -test('only = true, skip = true', { only: true, skip: true }); |
| 17 | +test('only = true, skip = string', { only: true, skip: 'skip message' }, common.mustNotCall()); |
| 18 | +test('only = true, skip = true', { only: true, skip: true }, common.mustNotCall()); |
19 | 19 |
|
20 | 20 | // An 'only' test with subtests.
|
21 |
| -test('only = true, with subtests', { only: true }, async (t) => { |
| 21 | +test('only = true, with subtests', { only: true }, common.mustCall(async (t) => { |
22 | 22 | // These subtests should run.
|
23 |
| - await t.test('running subtest 1'); |
24 |
| - await t.test('running subtest 2'); |
| 23 | + await t.test('running subtest 1', common.mustCall()); |
| 24 | + await t.test('running subtest 2', common.mustCall()); |
25 | 25 |
|
26 | 26 | // Switch the context to only execute 'only' tests.
|
27 | 27 | t.runOnly(true);
|
28 |
| - await t.test('skipped subtest 1'); |
29 |
| - await t.test('skipped subtest 2'); |
30 |
| - await t.test('running subtest 3', { only: true }); |
| 28 | + await t.test('skipped subtest 1', common.mustNotCall()); |
| 29 | + await t.test('skipped subtest 2'), common.mustNotCall(); |
| 30 | + await t.test('running subtest 3', { only: true }, common.mustCall()); |
31 | 31 |
|
32 | 32 | // Switch the context back to execute all tests.
|
33 | 33 | t.runOnly(false);
|
34 |
| - await t.test('running subtest 4', async (t) => { |
| 34 | + await t.test('running subtest 4', common.mustCall(async (t) => { |
35 | 35 | // These subtests should run.
|
36 |
| - await t.test('running sub-subtest 1'); |
37 |
| - await t.test('running sub-subtest 2'); |
| 36 | + await t.test('running sub-subtest 1', common.mustCall()); |
| 37 | + await t.test('running sub-subtest 2', common.mustCall()); |
38 | 38 |
|
39 | 39 | // Switch the context to only execute 'only' tests.
|
40 | 40 | t.runOnly(true);
|
41 |
| - await t.test('skipped sub-subtest 1'); |
42 |
| - await t.test('skipped sub-subtest 2'); |
43 |
| - }); |
| 41 | + await t.test('skipped sub-subtest 1', common.mustNotCall()); |
| 42 | + await t.test('skipped sub-subtest 2', common.mustNotCall()); |
| 43 | + })); |
44 | 44 |
|
45 | 45 | // Explicitly do not run these tests.
|
46 |
| - await t.test('skipped subtest 3', { only: false }); |
47 |
| - await t.test('skipped subtest 4', { skip: true }); |
48 |
| -}); |
| 46 | + await t.test('skipped subtest 3', { only: false }, common.mustNotCall()); |
| 47 | + await t.test('skipped subtest 4', { skip: true }, common.mustNotCall()); |
| 48 | +})); |
49 | 49 |
|
50 |
| -describe.only('describe only = true, with subtests', () => { |
51 |
| - it.only('`it` subtest 1 should run', () => {}); |
| 50 | +describe.only('describe only = true, with subtests', common.mustCall(() => { |
| 51 | + it.only('`it` subtest 1 should run', common.mustCall()); |
52 | 52 |
|
53 |
| - it('`it` subtest 2 should not run', async () => {}); |
54 |
| -}); |
| 53 | + it('`it` subtest 2 should not run', common.mustNotCall()); |
| 54 | +})); |
55 | 55 |
|
56 |
| -describe.only('describe only = true, with a mixture of subtests', () => { |
57 |
| - it.only('`it` subtest 1', () => {}); |
| 56 | +describe.only('describe only = true, with a mixture of subtests', common.mustCall(() => { |
| 57 | + it.only('`it` subtest 1', common.mustCall()); |
58 | 58 |
|
59 |
| - it.only('`it` async subtest 1', async () => {}); |
| 59 | + it.only('`it` async subtest 1', common.mustCall(async () => {})); |
60 | 60 |
|
61 |
| - it('`it` subtest 2 only=true', { only: true }); |
| 61 | + it('`it` subtest 2 only=true', { only: true }, common.mustCall()); |
62 | 62 |
|
63 |
| - it('`it` subtest 2 only=false', { only: false }, () => { |
64 |
| - throw new Error('This should not run'); |
65 |
| - }); |
| 63 | + it('`it` subtest 2 only=false', { only: false }, common.mustNotCall()); |
66 | 64 |
|
67 |
| - it.skip('`it` subtest 3 skip', () => { |
68 |
| - throw new Error('This should not run'); |
69 |
| - }); |
| 65 | + it.skip('`it` subtest 3 skip', common.mustNotCall()); |
70 | 66 |
|
71 |
| - it.todo('`it` subtest 4 todo', { only: false }, () => { |
72 |
| - throw new Error('This should not run'); |
73 |
| - }); |
| 67 | + it.todo('`it` subtest 4 todo', { only: false }, common.mustNotCall()); |
74 | 68 |
|
75 |
| - test.only('`test` subtest 1', () => {}); |
| 69 | + test.only('`test` subtest 1', common.mustCall()); |
76 | 70 |
|
77 |
| - test.only('`test` async subtest 1', async () => {}); |
| 71 | + test.only('`test` async subtest 1', common.mustCall(async () => {})); |
78 | 72 |
|
79 |
| - test('`test` subtest 2 only=true', { only: true }); |
| 73 | + test('`test` subtest 2 only=true', { only: true }, common.mustCall()); |
80 | 74 |
|
81 |
| - test('`test` subtest 2 only=false', { only: false }, () => { |
82 |
| - throw new Error('This should not run'); |
83 |
| - }); |
| 75 | + test('`test` subtest 2 only=false', { only: false }, common.mustNotCall()); |
84 | 76 |
|
85 |
| - test.skip('`test` subtest 3 skip', () => { |
86 |
| - throw new Error('This should not run'); |
87 |
| - }); |
| 77 | + test.skip('`test` subtest 3 skip', common.mustNotCall()); |
88 | 78 |
|
89 |
| - test.todo('`test` subtest 4 todo', { only: false }, () => { |
90 |
| - throw new Error('This should not run'); |
91 |
| - }); |
92 |
| -}); |
| 79 | + test.todo('`test` subtest 4 todo', { only: false }, common.mustNotCall()); |
| 80 | +})); |
93 | 81 |
|
94 |
| -describe.only('describe only = true, with subtests', () => { |
95 |
| - test.only('subtest should run', () => {}); |
| 82 | +describe.only('describe only = true, with subtests', common.mustCall(() => { |
| 83 | + test.only('subtest should run', common.mustCall()); |
96 | 84 |
|
97 |
| - test('async subtest should not run', async () => {}); |
| 85 | + test('async subtest should not run', common.mustNotCall()); |
98 | 86 |
|
99 |
| - test('subtest should be skipped', { only: false }, () => {}); |
100 |
| -}); |
| 87 | + test('subtest should be skipped', { only: false }, common.mustNotCall()); |
| 88 | +})); |
| 89 | + |
| 90 | +describe('describe only = undefined, with subtests', common.mustCall(() => { |
| 91 | + test('async subtest should not run', common.mustNotCall()); |
| 92 | +})); |
| 93 | + |
| 94 | +describe('describe only = false, with subtests', { only: false }, common.mustCall(() => { |
| 95 | + test('async subtest should not run', common.mustNotCall()); |
| 96 | +})); |
0 commit comments