MCPcopy
hub / github.com/Effect-TS/effect / throwsAsync

Function throwsAsync

packages/vitest/src/utils.ts:160–177  ·  view source on GitHub ↗
(
  thunk: () => Promise<void>,
  error?: Error | ((u: unknown) => undefined),
  ..._: Array<never>
)

Source from the content-addressed store, hash-verified

158 * @since 0.21.0
159 */
160export async function throwsAsync(
161 thunk: () => Promise<void>,
162 error?: Error | ((u: unknown) => undefined),
163 ..._: Array<never>
164) {
165 try {
166 await thunk()
167 fail("Expected to throw an error")
168 } catch (e) {
169 if (error !== undefined) {
170 if (Predicate.isFunction(error)) {
171 error(e)
172 } else {
173 deepStrictEqual(e, error)
174 }
175 }
176 }
177}
178
179// ----------------------------
180// Option

Callers 1

Runtime.test.tsFile · 0.90

Calls 3

failFunction · 0.70
deepStrictEqualFunction · 0.70
errorFunction · 0.50

Tested by

no test coverage detected