← All work

Testing · mastra-ai/mastra

Test processor schema validation and union routing

Adds a dedicated Vitest suite for the Zod schemas in Mastra's processor step schema module. The tests exercise runtime validation without changing production behavior or adding dependencies.

The problem

The processor step schemas gate data entering the processor pipeline before agent execution. Their validation contracts include tool invocation states, message format versions, role constraints, and phase-specific fields, making both acceptance and rejection behavior important to test.

The approach

Introduces a test file with shared helpers that assert success or failure through Zod's safeParse(). Cases cover message parts, composed messages, processor phases, and discriminated union variants, including missing fields and invalid discriminator values. The suite also checks ISO-string-to-Date coercion, and a patch changeset records the additive coverage.

What changed

The repository gains executable checks for processor schema validation contracts, including malformed-input rejection and valid union variants. Production schemas and runtime behavior remain unchanged.

  • typescript
  • vitest
  • zod
  • schema-validation
  • discriminated-unions
  • processors