---
summary: Modernized testing surface — createMockLogger, createInMemoryStorage, custom Vitest matchers, Vitest 4 projects config, shared test helpers
breaking: false
---

# 0.4.0 — 2026-04-19

Modernizes the testing surface: new public helpers under `/testing`, custom Vitest matchers, Vitest 4 `projects` config, and consolidated test infrastructure. No behavior changes to the framework runtime.

## Added

- **`createMockLogger()`** (`@cyanheads/mcp-ts-core/testing`) — returns a `ContextLogger` whose calls are recorded on an inspectable `calls` array. Complements `createMockContext()` for unit-testing code that accepts a `ContextLogger` standalone.
- **`createInMemoryStorage(options?)`** (`@cyanheads/mcp-ts-core/testing`) — returns a real `StorageService` backed by `InMemoryProvider`. Uses the production code path, so tenant isolation, TTL, key validation, and list pagination all match live behavior — no hand-rolled fake required when unit-testing services that depend on storage.
- **`MockContextLogger` type export** — the shape returned by `createMockLogger()`.
- **Vitest 4 `projects` config** — `vitest.config.ts` now splits `unit`, `compliance`, `smoke`, and `fuzz` into filterable projects. Run individually with `bun run test:unit|test:smoke|test:fuzz|test:compliance` or all at once with `bun run test`.
- **Custom Vitest matchers** — `toBeMcpError(code?)` and `toHaveJsonRpcCode(code)` for MCP-aware assertions. Registered globally in `tests/setup.ts`.
- **Shared test helpers** — `tests/helpers/context-helpers.ts` centralizes `createMockLogger`, `createFakeStorage`, `makeRequestContext`, and `makeContextDeps` (previously duplicated across multiple test files).
- **`templates/vitest.config.ts`** — scaffolded consumer servers now ship the `projects` pattern with a `unit` project active and commented examples for `smoke`, `fuzz`, and `integration` projects.

## Changed

- **`tests/setup.ts`** — now registers the custom matchers before tests run. Same pre-mock behavior otherwise (MCP SDK stdio/mcp modules + chrono-node).
- **`tests/unit/context.test.ts` / `tests/unit/testing/mockContextFidelity.test.ts`** — refactored to use the shared helpers; ~100 lines of duplicated fake-storage scaffolding removed.

## Fixed

- **`tests/unit/mcp-server/transports/auth/lib/checkScopes.test.ts`** — latent `vi.mock` hoisting bug (bare `const mockConfig` declared above the mock factory) was masked by the old import chain. `@/testing` now transitively imports `@/config` via `StorageService → logger → config`, which surfaced the reference error. Migrated to the `vi.hoisted` pattern.

## Removed

- **`tests/helpers/mock-server.ts`, `tests/helpers/mock-handlers.ts`** — dead MSW infrastructure; no test imported them.
- **`msw` devDependency** — unused after removing the helpers.

## Tests

- Suite grew from 2213 → 2230 tests (+17 net). 136 files pass, 1 skipped. Runtime ~8–10s.
- New coverage: `tests/unit/helpers/matchers.test.ts` (11 tests) and `tests/unit/testing/exports.test.ts` (6 tests).
- `bun run devcheck --test` fully green: typecheck, biome, depcheck, security, outdated, and all tests.
