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.tsOutput 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
| Flag | Description |
|---|---|
| --input | Source file to analyze |
| --output | Custom output path |
| --watch | Regenerate on source changes |
| --coverage | Target coverage threshold (80) |
Pro tip: Pair with coverage-reporter to enforce thresholds in CI.