Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs - Expect API - toThrow - Added a note about the type of value thrown #8772

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- `[jest-runtime]` [**BREAKING**] Remove long-deprecated `require.requireActual` and `require.requireMock` methods ([#9854](https://github.com/facebook/jest/pull/9854))
- `[expect, jest-mock, pretty-format]` [**BREAKING**] Remove `build-es5` from package ([#9945](https://github.com/facebook/jest/pull/9945))
- `[jest-haste-map]` [**BREAKING**] removed `providesModuleNodeModules` ([#8535](https://github.com/facebook/jest/pull/8535))
- `[docs]` Add note to `toThrow` Expect API ([#8772](https://github.com/facebook/jest/pull/8772))

### Performance

Expand Down
2 changes: 1 addition & 1 deletion docs/ExpectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ test('throws on octopus', () => {
});
```

> Note: You must wrap the code in a function, otherwise the error will not be caught and the assertion will fail.
> Note: You must wrap the code in a function, otherwise the error will not be caught and the assertion will fail. Furthermore, `.toThrow` will check that the value thrown is the instance of the Error class, and if not it will not be detected.

You can provide an optional argument to test that a specific error is thrown:

Expand Down