⚡ PromptLoot

Home › Coding & Cursor Rules

Generate Unit Tests Prompt

Get thorough unit tests, including edge cases, for any function.

Added

Write unit tests for this code using [pytest / vitest / jest]:

```
[PASTE CODE]
```

Requirements:
- Cover the happy path, edge cases (empty, zero, negative, very large, unicode), and error cases.
- One behavior per test. Test names describe the behavior, e.g. test_returns_empty_list_when_no_matches.
- Mock only external I/O (network, disk, time). Do not mock the code under test.
- After the tests, list any behavior that seems like a bug or is ambiguous.

How to use it

  1. Click Copy template.
  2. Paste into ChatGPT, Claude, Grok, Cursor, or your agent framework.
  3. Replace the [BRACKETED] parts with your details.
Sponsor this page · Reach builders who use AI daily. Get details

FAQ

What framework should I pick?

Use whatever your project already uses. pytest for Python, vitest for Vite projects.

Why list ambiguous behavior?

Writing tests often exposes bugs; this makes the AI tell you instead of hiding them.

Get 3 new templates every week

Free. Unsubscribe anytime.

Related templates

Explain This Codebase Prompt

Onboard yourself to an unfamiliar repo fast.

Safe Refactor Prompt

Refactor messy code without changing behavior.

AGENTS.md Starter Template for Claude Code, Codex & Cursor

A drop-in AGENTS.md (or CLAUDE.md) that tells coding agents how your repo works, how to verify changes, and what never to touch.

Browse all Coding & Cursor Rules templates

New on PromptLoot

2D Game Asset Rules for AI Agents: Sprites & Colliders

An ASSETS.md for Claude Code, Cursor, or Codex in Godot, Unity, Phaser, or Canvas: sprite sheet layout, naming, pixel-art import, animations, and colliders.

Agent Auto-Approve Policy: What AI Agents May Merge Alone

A policy file that sorts every PR an AI agent reviews into auto-merge, human review, or blocked: docs and tests yes; payments, auth, and secrets never.
PromptLoot Pro Pack · 200+ advanced templates, agent workflows, and Cursor rules bundles. Coming soon