Test Generation for Cursor

Developer Toolscursor-ai-tipsfile_to_testtest_frameworktest_file_path

The @-mention gives Cursor the actual file content. Requiring it to check existing test patterns first ensures new tests match the project's style rather than generic defaults.

Prompt
Generate tests for @{{file_to_test}}.

Test framework: {{test_framework}}
Test file location: {{test_file_path}}

Requirements:
- Look at existing tests in the project first (check {{test_directory}}) and match their patterns
- Test the public exports only
- Include these categories:
  * Happy path (normal inputs, expected outputs)
  * Edge cases (empty, null, boundary values)
  * Error cases (invalid input, network failures, timeouts)
- Mock {{dependencies_to_mock}} using the project's existing mock patterns
- Each test name should describe the scenario: "should [expected behavior] when [condition]"

Do NOT test implementation details like private functions or internal state.

Variables to customize

{{file_to_test}}{{test_framework}}{{test_file_path}}{{test_directory}}{{dependencies_to_mock}}

Why this prompt works

The @-mention gives Cursor the actual file content. Requiring it to check existing test patterns first ensures new tests match the project's style rather than generic defaults.

What you get when you save this prompt

Your workspace unlocks powerful tools to iterate and improve.

AI OPTIMIZE

AI Optimization

One-click improvement with structure analysis and pattern suggestions.

VERSION DIFF

Version History

Track every edit. Compare versions side-by-side with word-level diffs.

ORGANIZE
Development
Code Review
Testing
Marketing

Folders & Tags

Organize your library with nested folders, tags, and drag-and-drop.

MCP
$ npm i -g @promptingbox/mcp
Claude · Cursor · ChatGPT

Use Everywhere

Access prompts from Claude, Cursor, ChatGPT & more via MCP integration.

Your prompts, organized

Save, version, and access your best prompts across ChatGPT, Claude, Cursor, and more.