@@ -125,34 +125,6 @@ Any subtests that are still outstanding when their parent finishes
125125are cancelled and treated as failures. Any subtest failures cause the parent
126126test to fail.
127127
128- ## Skipping tests
129-
130- Individual tests can be skipped by passing the ` skip ` option to the test, or by
131- calling the test context's ` skip() ` method as shown in the
132- following example.
133-
134- ``` js
135- // The skip option is used, but no message is provided.
136- test (' skip option' , { skip: true }, (t ) => {
137- // This code is never executed.
138- });
139-
140- // The skip option is used, and a message is provided.
141- test (' skip option with message' , { skip: ' this is skipped' }, (t ) => {
142- // This code is never executed.
143- });
144-
145- test (' skip() method' , (t ) => {
146- // Make sure to return here as well if the test contains additional logic.
147- t .skip ();
148- });
149-
150- test (' skip() method with message' , (t ) => {
151- // Make sure to return here as well if the test contains additional logic.
152- t .skip (' this is skipped' );
153- });
154- ```
155-
156128## Rerunning failed tests
157129
158130The test runner supports persisting the state of the run to a file, allowing
@@ -193,37 +165,6 @@ When the `--test-rerun-failures` option is used, the test runner will only run t
193165node --test-rerun-failures /path/to/state/file
194166```
195167
196- ## TODO tests
197-
198- Individual tests can be marked as flaky or incomplete by passing the ` todo `
199- option to the test, or by calling the test context's ` todo() ` method, as shown
200- in the following example. These tests represent a pending implementation or bug
201- that needs to be fixed. TODO tests are executed, but are not treated as test
202- failures, and therefore do not affect the process exit code. If a test is marked
203- as both TODO and skipped, the TODO option is ignored.
204-
205- ``` js
206- // The todo option is used, but no message is provided.
207- test (' todo option' , { todo: true }, (t ) => {
208- // This code is executed, but not treated as a failure.
209- throw new Error (' this does not fail the test' );
210- });
211-
212- // The todo option is used, and a message is provided.
213- test (' todo option with message' , { todo: ' this is a todo test' }, (t ) => {
214- // This code is executed.
215- });
216-
217- test (' todo() method' , (t ) => {
218- t .todo ();
219- });
220-
221- test (' todo() method with message' , (t ) => {
222- t .todo (' this is a todo test and is not treated as a failure' );
223- throw new Error (' this does not fail the test' );
224- });
225- ```
226-
227168## ` describe() ` and ` it() ` aliases
228169
229170Suites and tests can also be written using the ` describe() ` and ` it() `
@@ -258,6 +199,65 @@ import { describe, it } from 'node:test';
258199const { describe , it } = require (' node:test' );
259200```
260201
202+ ## Skipping tests
203+
204+ Individual tests can be skipped by passing the ` skip ` option to the test, or by
205+ calling the test context's ` skip() ` method as shown in the
206+ following example.
207+
208+ ``` js
209+ // The skip option is used, but no message is provided.
210+ test (' skip option' , { skip: true }, (t ) => {
211+ // This code is never executed.
212+ });
213+
214+ // The skip option is used, and a message is provided.
215+ test (' skip option with message' , { skip: ' this is skipped' }, (t ) => {
216+ // This code is never executed.
217+ });
218+
219+ test (' skip() method' , (t ) => {
220+ // Make sure to return here as well if the test contains additional logic.
221+ t .skip ();
222+ });
223+
224+ test (' skip() method with message' , (t ) => {
225+ // Make sure to return here as well if the test contains additional logic.
226+ t .skip (' this is skipped' );
227+ });
228+ ```
229+
230+ ## TODO tests
231+
232+ Individual tests can be marked as flaky or incomplete by passing the ` todo `
233+ option to the test, or by calling the test context's ` todo() ` method, as shown
234+ in the following example. These tests represent a pending implementation or bug
235+ that needs to be fixed. TODO tests are executed, but are not treated as test
236+ failures, and therefore do not affect the process exit code. If a test is marked
237+ as both TODO and skipped, the TODO option is ignored.
238+
239+ ``` js
240+ // The todo option is used, but no message is provided.
241+ test (' todo option' , { todo: true }, (t ) => {
242+ // This code is executed, but not treated as a failure.
243+ throw new Error (' this does not fail the test' );
244+ });
245+
246+ // The todo option is used, and a message is provided.
247+ test (' todo option with message' , { todo: ' this is a todo test' }, (t ) => {
248+ // This code is executed.
249+ });
250+
251+ test (' todo() method' , (t ) => {
252+ t .todo ();
253+ });
254+
255+ test (' todo() method with message' , (t ) => {
256+ t .todo (' this is a todo test and is not treated as a failure' );
257+ throw new Error (' this does not fail the test' );
258+ });
259+ ```
260+
261261## Expecting tests to fail
262262
263263<!-- YAML
0 commit comments