← All work

Testing·mastra-ai/mastra

Add tests for Mastra channel formatting and workflow helpers

Added two Vitest suites covering nine channel-formatting functions and five workflow utilities in @mastra/core. The change tests existing behavior without modifying production code or adding dependencies.

The problem

The channel-formatting and workflow utility modules had no unit tests despite their use throughout the framework. Their responsibilities include tool-message rendering, internal metadata cleanup, serialized error hydration, and workflow step identification, each with edge cases requiring explicit assertions.

The approach

Added formatting tests for prefix removal, argument filtering and serialization, truncation, error prefixes, and plain-text tool lifecycle messages. Added workflow tests for immutable result cleanup, error hydration, step variants, resume-label filtering, and one-time deprecation warnings. Card-rendering paths remain outside these unit suites because they require Chat SDK initialization; deprecation tests use unique parameter names to avoid module-level warning-state interference.

What changed

Introduced two test files with 644 added lines that assert formatting and workflow-helper behavior, including null inputs, metadata preservation, and reference identity. Runtime behavior and dependencies are unchanged.

  • typescript
  • vitest
  • unit-testing
  • channels
  • workflows
  • serialization