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

Function throwsAsync

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

Source from the content-addressed store, hash-verified

185 * @since 4.0.0
186 */
187export async function throwsAsync(
188 thunk: () => Promise<void>,
189 error?: Error | ((u: unknown) => undefined),
190 ..._: Array<never>
191) {
192 try {
193 await thunk()
194 } catch (e) {
195 if (error !== undefined) {
196 if (Predicate.isFunction(error)) {
197 error(e)
198 } else {
199 deepStrictEqual(e, error)
200 }
201 }
202 return
203 }
204 fail("Expected to throw an error")
205}
206
207// ----------------------------
208// Option

Callers

nothing calls this directly

Calls 3

deepStrictEqualFunction · 0.70
failFunction · 0.70
errorFunction · 0.50

Tested by

no test coverage detected