Covers Vitest setup, in-memory and SQL contract tests, the Miniflare MCP worker test, Storybook UI tests, and the full quality-check suite.
The backend test suite is built on Vitest and uses a hybrid layout: tests that belong to a specific module live beside the source in backend/src/**/*.test.ts, while shared support utilities, repository contracts, and cross-boundary integration workflows live centrally under backend/test/.
The repository contract is defined once in test/contracts/repository-contract.ts and then run against two different adapter implementations, making it straightforward to verify that both adapters satisfy the same behavioral guarantees.
In-Memory
SQL (D1 via Miniflare)
Provides InMemoryCoffeeRepositoriesLive to the Effect runtime — no database or external process required:
// test/contracts/in-memory-repositories.test.tsimport * as Effect from "effect/Effect";import { InMemoryCoffeeRepositoriesLive } from "#external/live";import { defineRepositoryContract } from "./repository-contract.ts";defineRepositoryContract("in-memory repositories", (effect) => Effect.runPromise(effect.pipe(Effect.provide(InMemoryCoffeeRepositoriesLive))),);
Spins up a Miniflare D1 harness in beforeAll, resets state in beforeEach, and tears down in afterAll:
The file backend/src/presentation/mcp/miniflare.worker.test.ts exercises the full MCP HTTP surface end-to-end inside a Cloudflare Worker environment using Miniflare. It validates tools, resources, prompts, and protocol headers without deploying to Cloudflare.Run it directly:
bun run --cwd backend test src/presentation/mcp/miniflare.worker.test.ts
The suite covers three scenarios:
Catalog surface — asserts the expected tool names, resource URIs, and prompt names returned by tools/list, resources/list, and prompts/list
Order resources — places a latte order via tools/call and reads it back through resources/read
Prompts and protocol headers — fetches the recommend-drink prompt and checks the Mcp-Protocol-Version response header
// snapshot of the expected MCP surface from the testassert.deepStrictEqual(toolNames, [ "cancel_order", "get_order", "list_menu", "list_orders", "mark_ready", "pick_up_order", "place_order", "start_brewing",]);assert.deepStrictEqual(resourceUris, ["coffee://menu", "coffee://orders/open"]);assert.deepStrictEqual(promptNames, ["recommend-drink", "summarize-open-orders"]);
The check script runs typechecking, linting (standard and custom), format verification, and tests in a single command:
bun run check
This expands to:
turbo run typecheck lint lint:custom fmt:check test
To run the same suite but skip workspaces unaffected by your current branch:
bun run check:affected
bun run check:affected is the fastest way to validate your changes before pushing. Turborepo hashes task inputs and skips any workspace whose source files have not changed.