MCPcopy
hub / github.com/Effect-TS/effect / throws

Function throws

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

Source from the content-addressed store, hash-verified

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

Callers 15

assertCookieErrorFunction · 0.90
Either.test.tsFile · 0.90
Option.test.tsFile · 0.90
Chunk.test.tsFile · 0.90
BigInt.test.tsFile · 0.90
HashMap.test.tsFile · 0.90
Context.test.tsFile · 0.90
BigDecimal.test.tsFile · 0.90
Redacted.test.tsFile · 0.90
Function.test.tsFile · 0.90
Cron.test.tsFile · 0.90

Calls 3

failFunction · 0.70
deepStrictEqualFunction · 0.70
errorFunction · 0.50

Tested by 5

assertCookieErrorFunction · 0.72
expectAsyncTreeFunction · 0.72
expectAsyncIssuesFunction · 0.72
expectErrorFunction · 0.72
expectErrorFunction · 0.72