← All work

Testing·mastra-ai/mastra

Test Zod inspection helpers across v3 and v4 schema shapes

Adds a Vitest suite for eight Zod utilities in Mastra core. Coverage addresses schema detection, type-name normalization, object extension, definition lookup, and nested wrapper unwrapping without changing production code.

The problem

The PR describes eight helpers with no existing tests despite use at more than 53 locations. These utilities normalize differences between Zod 3 and Zod 4 internals, making their behavior relevant to schema introspection, tool input validation, and output type detection.

The approach

Adds a dedicated test file using real schemas imported from zod/v4 and minimal plain objects to simulate Zod 3 structures. Tests cover valid and invalid duck-typed inputs, definition precedence, object-extension behavior, and extraction of inner schema types. Nested wrapper cases check recursive unwrapping and stopping at object or array schemas.

What changed

Introduces a test-only suite covering all eight helpers, with assertions for compatibility behavior and edge cases. No production behavior or dependencies change.

  • typescript
  • vitest
  • zod
  • unit-tests
  • schema-introspection
  • compatibility