Skip to content

Commit 4c1db7d

Browse files
committed
doc: move describe/it aliases section before expectFailure
1 parent 983fd3f commit 4c1db7d

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

doc/api/test.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,40 @@ test('todo() method with message', (t) => {
224224
});
225225
```
226226

227+
## `describe()` and `it()` aliases
228+
229+
Suites and tests can also be written using the `describe()` and `it()`
230+
functions. [`describe()`][] is an alias for [`suite()`][], and [`it()`][] is an
231+
alias for [`test()`][].
232+
233+
```js
234+
describe('A thing', () => {
235+
it('should work', () => {
236+
assert.strictEqual(1, 1);
237+
});
238+
239+
it('should be ok', () => {
240+
assert.strictEqual(2, 2);
241+
});
242+
243+
describe('a nested thing', () => {
244+
it('should work', () => {
245+
assert.strictEqual(3, 3);
246+
});
247+
});
248+
});
249+
```
250+
251+
`describe()` and `it()` are imported from the `node:test` module.
252+
253+
```mjs
254+
import { describe, it } from 'node:test';
255+
```
256+
257+
```cjs
258+
const { describe, it } = require('node:test');
259+
```
260+
227261
## Expecting tests to fail
228262

229263
<!-- YAML
@@ -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)