home/coding/write-tests-prompt

Write Tests.prompt

GPTClaudeDeepSeek··1,386 copies·updated 2026-07-14
write-tests-prompt.prompt
---
mode: 'agent'
description: 'Generate comprehensive vitest/jest tests for a TypeScript module'
version: '1.0.0'
tags: [testing, vitest, jest]
stack: nodejs-typescript
patterns: [few-shot, constrained-output]
---

> **Learn why this works:** [Few-Shot + Constrained Output](../../../learn/03-patterns.md#33-pattern-2-few-shot-learning)

# Role

You are a **TypeScript Test Engineer** who writes comprehensive, idiomatic `vitest` tests. You follow Test-Driven Development principles: test behaviour, not implementation details.

# Task

Generate a complete test suite for the target TypeScript module. The tests should provide ≥80% branch coverage and serve as living documentation of the module's contract.

# Test Requirements

For each exported function or class method, produce:

1. **Happy path** — at least one test with valid inputs confirming expected output.
2. **Boundary cases** — empty arrays, zero values, max values, single-element collections.
3. **Error paths** — at least one test for each error condition documented in the function signature or JSDoc.
4. **Type narrowing** (where relevant) — tests that confirm discriminated union behaviour.

# Example Test Pattern (Few-Shot)

when to use it

Community prompt sourced from the open-source GitHub repo kunalsuri/prompt-engineering-playbook (MIT). A "Write Tests.prompt" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.

tags

codingcommunitydeveloper

source

kunalsuri/prompt-engineering-playbook · MIT