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

Method fail

packages/effect/src/testing/TestSchema.ts:397–409  ·  view source on GitHub ↗

* Asserts that decoding `input` fails and the stringified issue equals * `message`. * * **When to use** * * Use to verify that invalid decoding input produces the expected issue text. * * **Example** (Asserting a decoding failure) * * ```ts import.meta.vitest * import {

(
    this: Decoding<S>,
    input: unknown,
    message: string
  )

Source from the content-addressed store, hash-verified

395 * @see {@link succeed} for asserting successful decoding
396 */
397 async fail<S extends Schema.ConstraintDecoder<unknown, never>>(
398 this: Decoding<S>,
399 input: unknown,
400 message: string
401 ) {
402 const r = await Effect.runPromise(
403 this.decodeUnknownEffect(input, this.options?.parseOptions).pipe(
404 Effect.mapErrorEager(SchemaIssue.defaultFormatter),
405 Effect.result
406 )
407 )
408 assert.deepStrictEqual(r, Result.fail(message))
409 }
410 /**
411 * Returns a new {@link Decoding} instance with the given service injected into the decoding effect context.
412 *

Callers

nothing calls this directly

Calls 2

pipeMethod · 0.65
failMethod · 0.45

Tested by

no test coverage detected