* 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
)
| 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 | * |