Skip to content

Commit 013a47d

Browse files
committed
add test & fix lint
1 parent 4e09df4 commit 013a47d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

doc/api/test.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@ added:
15011501
changes:
15021502
- version: REPLACEME
15031503
pr-url: https://github.com/nodejs/node/pull/47586
1504-
description: The `before` function was added to TestContext
1504+
description: The `before` function was added to TestContext.
15051505
-->
15061506

15071507
An instance of `TestContext` is passed to each test function in order to
@@ -1528,7 +1528,6 @@ added: REPLACEME
15281528
This function is used to create a hook running before running a suite.
15291529
before subtest of the current test.
15301530

1531-
15321531
### `context.beforeEach([fn][, options])`
15331532

15341533
<!-- YAML

test/fixtures/test-runner/output/hooks.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const common = require('../../../common');
44
const assert = require('assert');
55
const { test, describe, it, before, after, beforeEach, afterEach } = require('node:test');
66

7+
before((t) => t.diagnostic('before 1 called'));
8+
79
describe('describe hooks', () => {
810
const testArr = [];
911
before(function() {
@@ -157,3 +159,5 @@ test('t.after() is called if test body throws', (t) => {
157159
});
158160
throw new Error('bye');
159161
});
162+
163+
before((t) => t.diagnostic('before 2 called'));

test/fixtures/test-runner/output/hooks.snapshot

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ not ok 11 - t.afterEach throws
467467
*
468468
*
469469
*
470-
*
471470
...
472471
# Subtest: 2
473472
ok 2 - 2
@@ -500,7 +499,6 @@ not ok 12 - afterEach when test fails
500499
*
501500
*
502501
*
503-
*
504502
...
505503
# Subtest: 2
506504
not ok 2 - 2
@@ -541,12 +539,11 @@ not ok 14 - t.after() is called if test body throws
541539
*
542540
*
543541
*
544-
*
545-
*
546-
*
547542
...
548543
# - after() called
549544
1..14
545+
# before 1 called
546+
# before 2 called
550547
# tests 38
551548
# suites 8
552549
# pass 14

0 commit comments

Comments
 (0)