← Back to Docs
Recipe

Recipe: Jest unit-test writer

Generate complete Jest test suites from source files using Meridian recipe templates.

Overview

This recipe scans a target source file, identifies exported functions and components, then emits a Jest spec with describe blocks, mock scaffolding, and edge-case assertions. Works with TypeScript, JSX, and plain JavaScript.

Usage

meridian recipe jest-writer --input src/utils/format.ts

Output lands in __tests__/format.test.ts. Pass --watch to regenerate on file change.

Generated output includes

  • describe block named after the module
  • it blocks for every top-level export
  • beforeEach / afterEach hooks when side-effects detected
  • jest.fn() mocks for imported dependencies
  • happy-path, null, and error-throw assertions

Options

FlagDescription
--inputSource file to analyze
--outputCustom output path
--watchRegenerate on source changes
--coverageTarget coverage threshold (80)

Pro tip: Pair with coverage-reporter to enforce thresholds in CI.