( thunk: () => void, error?: Error | ((u: unknown) => undefined), ..._: Array<never> )
| 142 | * @since 0.21.0 |
| 143 | */ |
| 144 | export function throws( |
| 145 | thunk: () => void, |
| 146 | error?: Error | ((u: unknown) => undefined), |
| 147 | ..._: Array<never> |
| 148 | ) { |
| 149 | try { |
| 150 | thunk(); |
| 151 | fail('Expected to throw an error'); |
| 152 | } catch (e) { |
| 153 | if (error !== undefined) { |
| 154 | if (Predicate.isFunction(error)) { |
| 155 | error(e); |
| 156 | } else { |
| 157 | deepStrictEqual(e, error); |
| 158 | } |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Asserts that `thunk` throws an error. |
nothing calls this directly
no test coverage detected