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

Function throwsAsync

packages/effect/test/utils/assert.ts:123–141  ·  view source on GitHub ↗
(
  thunk: () => Promise<void>,
  error?: Error | ((u: unknown) => undefined),
  ..._: Array<never>
)

Source from the content-addressed store, hash-verified

121}
122
123export async function throwsAsync(
124 thunk: () => Promise<void>,
125 error?: Error | ((u: unknown) => undefined),
126 ..._: Array<never>
127) {
128 try {
129 await thunk()
130 } catch (e) {
131 if (error !== undefined) {
132 if (Predicate.isFunction(error)) {
133 error(e)
134 } else {
135 deepStrictEqual(e, error)
136 }
137 }
138 return
139 }
140 fail("Expected to throw an error")
141}
142
143// ----------------------------
144// Option

Callers

nothing calls this directly

Calls 3

deepStrictEqualFunction · 0.70
failFunction · 0.70
errorFunction · 0.50

Tested by

no test coverage detected