MCPcopy Create free account
hub / github.com/CodeForBreakfast/eventsourcing / throwsAsync

Function throwsAsync

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

Source from the content-addressed store, hash-verified

166 * @since 0.21.0
167 */
168export async function throwsAsync(
169 thunk: () => Promise<void>,
170 error?: Error | ((u: unknown) => undefined),
171 ..._: Array<never>
172) {
173 try {
174 await thunk();
175 fail('Expected to throw an error');
176 } catch (e) {
177 if (error !== undefined) {
178 if (Predicate.isFunction(error)) {
179 error(e);
180 } else {
181 deepStrictEqual(e, error);
182 }
183 }
184 }
185}
186
187// ----------------------------
188// Option

Callers

nothing calls this directly

Calls 2

failFunction · 0.85
deepStrictEqualFunction · 0.85

Tested by

no test coverage detected