MCPcopy Create free account
hub / github.com/effect-app/libs / throwsAsync

Function throwsAsync

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

Source from the content-addressed store, hash-verified

98export function assertMatch(actual: string, regExp: RegExp, ..._: Array<never>) {
99 if (!regExp.test(actual)) {
100 fail(`Expected\n\n${actual}\n\nto match\n\n${regExp}`)
101 }
102}
103
104export function throws(thunk: () => void, error?: string | Error | ((u: unknown) => undefined), ..._: Array<never>) {
105 try {
106 thunk()
107 } catch (e) {
108 if (error !== undefined) {
109 if (Predicate.isString(error)) {
110 assertInstanceOf(e, Error)
111 strictEqual(e.message, error)
112 } else if (Predicate.isError(error)) {
113 deepStrictEqual(e, error)
114 } else {
115 error(e)
116 }
117 }
118 return
119 }
120 fail("Expected to throw an error")
121}

Callers

nothing calls this directly

Calls 3

deepStrictEqualFunction · 0.70
failFunction · 0.70
errorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…