You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/03-assertions.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -172,10 +172,11 @@ Finally, this returns a boolean indicating whether the assertion passed.
172
172
173
173
### `.throws(fn, expectation?, message?)`
174
174
175
-
Assert that an error is thrown. `fn` must be a function which should throw. The thrown value *must* be an error. It is returned so you can run more assertions against it. If the assertion fails then `undefined` is returned.
175
+
Assert that an error is thrown. `fn` must be a function which should throw. By default, the thrown value *must* be an error. It is returned so you can run more assertions against it. If the assertion fails then `undefined` is returned.
176
176
177
177
`expectation` can be an object with one or more of the following properties:
178
178
179
+
*`any`: a boolean only available in AVA 6, if `true` then the thrown value does not need to be an error. Defaults to `false`
179
180
*`instanceOf`: a constructor, the thrown error must be an instance of
180
181
*`is`: the thrown error must be strictly equal to `expectation.is`
181
182
*`message`: the following types are valid:
@@ -207,10 +208,11 @@ test('throws', t => {
207
208
208
209
Assert that an error is thrown. `thrower` can be an async function which should throw, or a promise that should reject. This assertion must be awaited.
209
210
210
-
The thrown value *must* be an error. It is returned so you can run more assertions against it. If the assertion fails then `undefined` is returned.
211
+
By default, the thrown value *must* be an error. It is returned so you can run more assertions against it. If the assertion fails then `undefined` is returned.
211
212
212
213
`expectation` can be an object with one or more of the following properties:
213
214
215
+
*`any`: a boolean only available in AVA 6, if `true` then the thrown value does not need to be an error. Defaults to `false`
214
216
*`instanceOf`: a constructor, the thrown error must be an instance of
215
217
*`is`: the thrown error must be strictly equal to `expectation.is`
0 commit comments