(thunk: () => void, error?: Error | ((u: unknown) => undefined), ..._: Array<never>)
| 161 | * @since 4.0.0 |
| 162 | */ |
| 163 | export function throws(thunk: () => void, error?: Error | ((u: unknown) => undefined), ..._: Array<never>) { |
| 164 | try { |
| 165 | thunk() |
| 166 | } catch (e) { |
| 167 | if (error !== undefined) { |
| 168 | if (Predicate.isFunction(error)) { |
| 169 | error(e) |
| 170 | } else if (error) { |
| 171 | deepStrictEqual(e, error) |
| 172 | } else { |
| 173 | throw e |
| 174 | } |
| 175 | } |
| 176 | return |
| 177 | } |
| 178 | fail("Expected to throw an error") |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Asserts that `thunk` throws or returns a rejected promise, optionally checking the failure value against an expected `Error` or validation function. |
nothing calls this directly
no test coverage detected