Skip to content

Commit

Permalink
add test & fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
atlowChemi committed Apr 16, 2023
1 parent 4e09df4 commit 013a47d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ added:
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/47586
description: The `before` function was added to TestContext
description: The `before` function was added to TestContext.
-->

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


### `context.beforeEach([fn][, options])`

<!-- YAML
Expand Down
4 changes: 4 additions & 0 deletions test/fixtures/test-runner/output/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const common = require('../../../common');
const assert = require('assert');
const { test, describe, it, before, after, beforeEach, afterEach } = require('node:test');

before((t) => t.diagnostic('before 1 called'));

describe('describe hooks', () => {
const testArr = [];
before(function() {
Expand Down Expand Up @@ -157,3 +159,5 @@ test('t.after() is called if test body throws', (t) => {
});
throw new Error('bye');
});

before((t) => t.diagnostic('before 2 called'));
7 changes: 2 additions & 5 deletions test/fixtures/test-runner/output/hooks.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ not ok 11 - t.afterEach throws
*
*
*
*
...
# Subtest: 2
ok 2 - 2
Expand Down Expand Up @@ -500,7 +499,6 @@ not ok 12 - afterEach when test fails
*
*
*
*
...
# Subtest: 2
not ok 2 - 2
Expand Down Expand Up @@ -541,12 +539,11 @@ not ok 14 - t.after() is called if test body throws
*
*
*
*
*
*
...
# - after() called
1..14
# before 1 called
# before 2 called
# tests 38
# suites 8
# pass 14
Expand Down

0 comments on commit 013a47d

Please sign in to comment.