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

Function throws

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

Source from the content-addressed store, hash-verified

142 * @since 0.21.0
143 */
144export function throws(
145 thunk: () => void,
146 error?: Error | ((u: unknown) => undefined),
147 ..._: Array<never>
148) {
149 try {
150 thunk();
151 fail('Expected to throw an error');
152 } catch (e) {
153 if (error !== undefined) {
154 if (Predicate.isFunction(error)) {
155 error(e);
156 } else {
157 deepStrictEqual(e, error);
158 }
159 }
160 }
161}
162
163/**
164 * Asserts that `thunk` throws an error.

Callers

nothing calls this directly

Calls 2

failFunction · 0.85
deepStrictEqualFunction · 0.85

Tested by

no test coverage detected