Skip to content

Commit

Permalink
doc,test: document common.mustSucceed
Browse files Browse the repository at this point in the history
  • Loading branch information
tniessen committed Oct 13, 2020
1 parent 476d930 commit c275bf0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/guides/writing-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ const server = http.createServer(common.mustCall((req, res) => {

```

**Note:** Many functions invoke their callback with an `err` value as the first
argument. It is not a good idea to simply pass `common.mustCall()` to those
because `common.mustCall()` will ignore the error. Use `common.mustSucceed()`
instead.

#### Countdown Module

The common [Countdown module](https://github.com/nodejs/node/tree/master/test/common#countdown-module)
Expand Down
9 changes: 9 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,15 @@ If `fn` is not provided, an empty function will be used.
Returns a function that triggers an `AssertionError` if it is invoked. `msg` is
used as the error message for the `AssertionError`.

### `mustSucceed([fn])`

* `fn` [<Function>][] default = () => {}
* return [<Function>][]

Returns a function that accepts arguments `(err, ...args)`. If `err` is not
`undefined` or `null`, it triggers an `AssertionError`. Otherwise, it calls
`fn(...args)`.

### `nodeProcessAborted(exitCode, signal)`

* `exitCode` [<number>][]
Expand Down

0 comments on commit c275bf0

Please sign in to comment.