Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/api/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -2601,6 +2601,19 @@ test('mocks a counting function', (t) => {
});
```

The following example creates a mock function that throws an error and uses
[`assert.throws`][] to verify it.

```js
test('mocks a function that throws an error', (t) => {
const fn = t.mock.fn(() => {
throw new Error('mocked error');
});

assert.throws(fn, /mocked error/);
});
```

### `mock.getter(object, methodName[, implementation][, options])`

<!-- YAML
Expand Down
Loading