(thunk: () => void, error?: Error | ((u: unknown) => undefined), ..._: Array<never>)
| 138 | * @since 0.21.0 |
| 139 | */ |
| 140 | export function throws(thunk: () => void, error?: Error | ((u: unknown) => undefined), ..._: Array<never>) { |
| 141 | try { |
| 142 | thunk() |
| 143 | fail("Expected to throw an error") |
| 144 | } catch (e) { |
| 145 | if (error !== undefined) { |
| 146 | if (Predicate.isFunction(error)) { |
| 147 | error(e) |
| 148 | } else { |
| 149 | deepStrictEqual(e, error) |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Asserts that `thunk` throws an error. |
searching dependent graphs…