MCPcopy Create free account
hub / github.com/Effect-TS/effect / throwsAsync

Function throwsAsync

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

Source from the content-addressed store, hash-verified

207 * @since 4.0.0
208 */
209export async function throwsAsync(
210 thunk: () => Promise<void>,
211 error?: Error | ((u: unknown) => undefined),
212 ..._: Array<never>
213) {
214 try {
215 await thunk()
216 } catch (e) {
217 if (error !== undefined) {
218 if (Predicate.isFunction(error)) {
219 error(e)
220 } else {
221 deepStrictEqual(e, error)
222 }
223 }
224 return
225 }
226 fail("Expected to throw an error")
227}
228
229// ----------------------------
230// Option

Callers

nothing calls this directly

Calls 3

deepStrictEqualFunction · 0.70
failFunction · 0.70
errorFunction · 0.50

Tested by

no test coverage detected