← All work

Testing·mastra-ai/mastra

Cover four untested core utilities with 32 unit tests

Adds 32 Vitest tests for deepMerge, deepEqual, omitKeys, and removeUndefinedValues in Mastra's core utility suite. The change is test-only, with no runtime behavior or public API changes.

The problem

Four functions exported from packages/core/src/utils.ts previously had no unit tests. Their behavior includes distinctions such as replacing arrays during merges, preserving falsy values when removing undefined entries, and comparing Date instances.

The approach

Extends the existing utils.test.ts suite using Vitest without mocks. Eight deepMerge tests cover recursive merging, target immutability, array replacement, and nullish source handling, while 14 deepEqual tests cover primitives, objects, arrays, dates, and mismatches. Five tests each exercise omitKeys and removeUndefinedValues, covering key removal, immutability, and preservation of values other than undefined.

What changed

Adds explicit test expectations for the four utilities without modifying implementations, dependencies, configuration, or public APIs.

  • typescript
  • vitest
  • unit-testing
  • core
  • utilities