Skip to content

Commit fa13ed6

Browse files
cjihrignodejs-github-bot
authored andcommitted
doc: add section explaining todo tests
This commit adds a section to the test runner docs explaining what a TODO test is. Refs: #49013 PR-URL: #52204 Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 7dfa475 commit fa13ed6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

doc/api/test.md

+31
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,37 @@ test('skip() method with message', (t) => {
162162
});
163163
```
164164

165+
## TODO tests
166+
167+
Individual tests can be marked as flaky or incomplete by passing the `todo`
168+
option to the test, or by calling the test context's `todo()` method, as shown
169+
in the following example. These tests represent a pending implementation or bug
170+
that needs to be fixed. TODO tests are executed, but are not treated as test
171+
failures, and therefore do not affect the process exit code. If a test is marked
172+
as both TODO and skipped, the TODO option is ignored.
173+
174+
```js
175+
// The todo option is used, but no message is provided.
176+
test('todo option', { todo: true }, (t) => {
177+
// This code is executed, but not treated as a failure.
178+
throw new Error('this does not fail the test');
179+
});
180+
181+
// The todo option is used, and a message is provided.
182+
test('todo option with message', { todo: 'this is a todo test' }, (t) => {
183+
// This code is executed.
184+
});
185+
186+
test('todo() method', (t) => {
187+
t.todo();
188+
});
189+
190+
test('todo() method with message', (t) => {
191+
t.todo('this is a todo test and is not treated as a failure');
192+
throw new Error('this does not fail the test');
193+
});
194+
```
195+
165196
## `describe()` and `it()` aliases
166197

167198
Suites and tests can also be written using the `describe()` and `it()`

0 commit comments

Comments
 (0)