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

Method fail

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

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

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

Source from the content-addressed store, hash-verified

535 * @see {@link succeed} for asserting successful encoding
536 */
537 async fail<S extends Schema.ConstraintEncoder<unknown, never>>(
538 this: Encoding<S>,
539 input: unknown,
540 message: string
541 ) {
542 const r = await Effect.runPromise(
543 this.encodeUnknownEffect(input, this.options?.parseOptions).pipe(
544 Effect.mapErrorEager(SchemaIssue.defaultFormatter),
545 Effect.result
546 )
547 )
548 assert.deepStrictEqual(r, Result.fail(message))
549 }
550 /**
551 * Returns a new {@link Encoding} instance with the given service injected into the encoding effect context.
552 *

Callers

nothing calls this directly

Calls 2

pipeMethod · 0.65
failMethod · 0.45

Tested by

no test coverage detected