diff --git a/CHANGELOG.md b/CHANGELOG.md index a8175d2a73b6..96c6c06afbed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/ExpectAPI.md b/docs/ExpectAPI.md index af1721ebf32a..330ce1c4ad68 100644 --- a/docs/ExpectAPI.md +++ b/docs/ExpectAPI.md @@ -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: