@@ -105,11 +105,11 @@ top level test with two subtests.
105105
106106``` js
107107test (' top level test' , async (t ) => {
108- await t .test (' subtest 1' , (t ) => {
108+ t .test (' subtest 1' , (t ) => {
109109 assert .strictEqual (1 , 1 );
110110 });
111111
112- await t .test (' subtest 2' , (t ) => {
112+ t .test (' subtest 2' , (t ) => {
113113 assert .strictEqual (2 , 2 );
114114 });
115115});
@@ -118,12 +118,7 @@ test('top level test', async (t) => {
118118> ** Note:** ` beforeEach ` and ` afterEach ` hooks are triggered
119119> between each subtest execution.
120120
121- In this example, ` await ` is used to ensure that both subtests have completed.
122- This is necessary because tests do not wait for their subtests to
123- complete, unlike tests created within suites.
124- Any subtests that are still outstanding when their parent finishes
125- are cancelled and treated as failures. Any subtest failures cause the parent
126- test to fail.
121+ Any subtest failures cause the parent test to fail.
127122
128123## Skipping tests
129124
@@ -241,20 +236,20 @@ that are not executed are omitted from the test runner output.
241236// The suite's 'only' option is set, so these tests are run.
242237test (' this test is run' , { only: true }, async (t ) => {
243238 // Within this test, all subtests are run by default.
244- await t .test (' running subtest' );
239+ t .test (' running subtest' );
245240
246241 // The test context can be updated to run subtests with the 'only' option.
247242 t .runOnly (true );
248- await t .test (' this subtest is now skipped' );
249- await t .test (' this subtest is run' , { only: true });
243+ t .test (' this subtest is now skipped' );
244+ t .test (' this subtest is run' , { only: true });
250245
251246 // Switch the context back to execute all tests.
252247 t .runOnly (false );
253- await t .test (' this subtest is now run' );
248+ t .test (' this subtest is now run' );
254249
255250 // Explicitly do not run these tests.
256- await t .test (' skipped subtest 3' , { only: false });
257- await t .test (' skipped subtest 4' , { skip: true });
251+ t .test (' skipped subtest 3' , { only: false });
252+ t .test (' skipped subtest 4' , { skip: true });
258253});
259254
260255// The 'only' option is not set, so this test is skipped.
@@ -309,13 +304,13 @@ multiple times (e.g. `--test-name-pattern="test 1"`,
309304
310305``` js
311306test (' test 1' , async (t ) => {
312- await t .test (' test 2' );
313- await t .test (' test 3' );
307+ t .test (' test 2' );
308+ t .test (' test 3' );
314309});
315310
316311test (' Test 4' , async (t ) => {
317- await t .test (' Test 5' );
318- await t .test (' test 6' );
312+ t .test (' Test 5' );
313+ t .test (' test 6' );
319314});
320315```
321316
@@ -3175,12 +3170,9 @@ before each subtest of the current test.
31753170``` js
31763171test (' top level test' , async (t ) => {
31773172 t .beforeEach ((t ) => t .diagnostic (` about to run ${ t .name } ` ));
3178- await t .test (
3179- ' This is a subtest' ,
3180- (t ) => {
3181- assert .ok (' some relevant assertion here' );
3182- },
3183- );
3173+ t .test (' This is a subtest' , (t ) => {
3174+ assert .ok (' some relevant assertion here' );
3175+ });
31843176});
31853177```
31863178
@@ -3238,12 +3230,9 @@ after each subtest of the current test.
32383230``` js
32393231test (' top level test' , async (t ) => {
32403232 t .afterEach ((t ) => t .diagnostic (` finished running ${ t .name } ` ));
3241- await t .test (
3242- ' This is a subtest' ,
3243- (t ) => {
3244- assert .ok (' some relevant assertion here' );
3245- },
3246- );
3233+ t .test (' This is a subtest' , (t ) => {
3234+ assert .ok (' some relevant assertion here' );
3235+ });
32473236});
32483237```
32493238
@@ -3458,10 +3447,8 @@ no-op.
34583447test (' top level test' , (t ) => {
34593448 // The test context can be set to run subtests with the 'only' option.
34603449 t .runOnly (true );
3461- return Promise .all ([
3462- t .test (' this subtest is now skipped' ),
3463- t .test (' this subtest is run' , { only: true }),
3464- ]);
3450+ t .test (' this subtest is now skipped' );
3451+ t .test (' this subtest is run' , { only: true });
34653452});
34663453```
34673454
@@ -3533,6 +3520,10 @@ added:
35333520 - v18.0.0
35343521 - v16.17.0
35353522changes:
3523+ - version:
3524+ - REPLACEME
3525+ pr-url: https://github.com/nodejs/node/pull/56664
3526+ description: This function no longer returns a `Promise`.
35363527 - version:
35373528 - v18.8.0
35383529 - v16.18.0
@@ -3577,14 +3568,13 @@ changes:
35773568 to this function is a [ ` TestContext ` ] [ ] object. If the test uses callbacks,
35783569 the callback function is passed as the second argument. ** Default:** A no-op
35793570 function.
3580- * Returns: {Promise} Fulfilled with ` undefined ` once the test completes.
35813571
35823572This function is used to create subtests under the current test. This function
35833573behaves in the same fashion as the top level [ ` test() ` ] [ ] function.
35843574
35853575``` js
35863576test (' top level test' , async (t ) => {
3587- await t .test (
3577+ t .test (
35883578 ' This is a subtest' ,
35893579 { only: false , skip: false , concurrency: 1 , todo: false , plan: 1 },
35903580 (t ) => {
0 commit comments