Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 94097a7

Browse filesBrowse files
lraveriaduh95
authored andcommitted
doc: move describe/it aliases section before expectFailure
PR-URL: #61567 Reviewed-By: Tierney Cyren <hello@bnb.im> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 6e1197a commit 94097a7
Copy full SHA for 94097a7

1 file changed

+62-62Lines changed: 62 additions & 62 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/test.md‎

Copy file name to clipboardExpand all lines: doc/api/test.md
+62-62Lines changed: 62 additions & 62 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -125,34 +125,6 @@ Any subtests that are still outstanding when their parent finishes
125125
are cancelled and treated as failures. Any subtest failures cause the parent
126126
test 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

158130
The test runner supports persisting the state of the run to a file, allowing
@@ -193,6 +165,68 @@ When the `--test-rerun-failures` option is used, the test runner will only run t
193165
node --test-rerun-failures /path/to/state/file
194166
```
195167

168+
## `describe()` and `it()` aliases
169+
170+
Suites and tests can also be written using the `describe()` and `it()`
171+
functions. [`describe()`][] is an alias for [`suite()`][], and [`it()`][] is an
172+
alias for [`test()`][].
173+
174+
```js
175+
describe('A thing', () => {
176+
it('should work', () => {
177+
assert.strictEqual(1, 1);
178+
});
179+
180+
it('should be ok', () => {
181+
assert.strictEqual(2, 2);
182+
});
183+
184+
describe('a nested thing', () => {
185+
it('should work', () => {
186+
assert.strictEqual(3, 3);
187+
});
188+
});
189+
});
190+
```
191+
192+
`describe()` and `it()` are imported from the `node:test` module.
193+
194+
```mjs
195+
import { describe, it } from 'node:test';
196+
```
197+
198+
```cjs
199+
const { describe, it } = require('node:test');
200+
```
201+
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+
196230
## TODO tests
197231

198232
Individual tests can be marked as flaky or incomplete by passing the `todo`
@@ -275,40 +309,6 @@ it.todo('should do the thing', { expectFailure: true }, () => {
275309
});
276310
```
277311

278-
## `describe()` and `it()` aliases
279-
280-
Suites and tests can also be written using the `describe()` and `it()`
281-
functions. [`describe()`][] is an alias for [`suite()`][], and [`it()`][] is an
282-
alias for [`test()`][].
283-
284-
```js
285-
describe('A thing', () => {
286-
it('should work', () => {
287-
assert.strictEqual(1, 1);
288-
});
289-
290-
it('should be ok', () => {
291-
assert.strictEqual(2, 2);
292-
});
293-
294-
describe('a nested thing', () => {
295-
it('should work', () => {
296-
assert.strictEqual(3, 3);
297-
});
298-
});
299-
});
300-
```
301-
302-
`describe()` and `it()` are imported from the `node:test` module.
303-
304-
```mjs
305-
import { describe, it } from 'node:test';
306-
```
307-
308-
```cjs
309-
const { describe, it } = require('node:test');
310-
```
311-
312312
## `only` tests
313313

314314
If Node.js is started with the [`--test-only`][] command-line option, or test

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.