Tests That Actually Catch Regressions
Generates a focused test suite around behaviour, edge cases and failure modes instead of shallow coverage padding.
The prompt
Remixed ·Fill in the variables
The prompt above updates live. Nothing leaves your browser.Remix it
One-click variations. Stack them, then copy.
Why this prompt works
Listing the contract and edge cases first makes the model think about what can break before it writes boilerplate. Banning private-helper tests and over-mocking keeps the suite useful after refactors, and the POSSIBLE BUG marker turns test writing into bug finding.
Framework: Chain-of-Thought. Asks the model to reason through explicit steps before answering.
Example
Illustrative, not a real model outputExample input
- [TEST_FRAMEWORK]
- Vitest
- [CODE_UNDER_TEST]
- export function slugify(s) { return s.toLowerCase().replace(/ /g, "-") }
What a good answer looks like (abridged)
How to use it
- Set the TEST_FRAMEWORK variable, paste the CODE_UNDER_TEST, then run the prompt.
- First list the contract, edge cases, and failure modes exactly as described.
- Write one‑assertion tests using the chosen framework, add "POSSIBLE BUG:" comments where needed.
ChatGPT tips
- Enclose generated test code in triple backticks so ChatGPT keeps formatting intact.
- Keep the three sections (contract, edge cases, failure modes) in the exact order for reliable output.
Common mistakes
- Skipping the contract list and jumping straight to test code.
- Testing private helpers or over‑mocking internal calls.
- Omitting edge‑case scenarios or forgetting the POSSIBLE BUG comment.
Guide generated with AI (openai/gpt-oss-120b) on 2026-12-06.
Frequently asked questions
Which AI model works best with the Tests That Actually Catch Regressions prompt?+
It is tuned for ChatGPT and also works in Claude, Gemini, Grok, DeepSeek. Put the output format (schema, table columns) near the top: ChatGPT follows explicit structure very reliably.
How do I use this prompt?+
Copy it, replace the 2 [VARIABLES] (test framework, code under test) with your details, then paste it into ChatGPT. You can fill the variables on this page and copy the finished version.
Is this prompt free to use?+
Yes. Every prompt on Promptnic is free to copy, adapt and use in personal or commercial work. A link back is appreciated, not required.
Why does this prompt work?+
Listing the contract and edge cases first makes the model think about what can break before it writes boilerplate. Banning private-helper tests and over-mocking keeps the suite useful after refactors, and the POSSIBLE BUG marker turns test writing into bug finding.
Related prompts
Strict JSON Extractor With Self-Check
Pulls structured data out of messy text into an exact JSON schema, with nulls instead of made-up values.
README That Gets People to Try Your Project
Writes a README with a one-line pitch, quick start that works on the first try, and honest limitations.
SQL Query Writer With Schema Check
Writes correct SQL from plain English, states assumptions about your schema and explains performance.
Error Message Translator
Explains a cryptic error in plain English, lists likely causes for your setup and gives the fix commands.
Regex Builder With Test Cases
Builds a regular expression from plain English and proves it with matching and non-matching examples.
Commit Message and PR Description Writer
Turns a diff into a conventional commit message and a reviewer-friendly PR description.