Test Scaffolding Prompt
Referencing the exact file with #file gives Copilot Chat the full function signature and dependencies. Specifying the test framework, naming convention, and what to mock prevents generic tests that need heavy editing.
Write unit tests for the {{functionName}} function in #file:{{filePath}}. Use {{testFramework}} with the following structure: - Group tests by behavior (describe blocks) - Cover: happy path, edge cases (empty input, null, boundary values), and error cases - Use descriptive test names: "should {{expectedBehavior}} when {{condition}}" - Mock {{dependenciesToMock}} using {{mockLibrary}} - Assert both return values and side effects
Variables to customize
Why this prompt works
Referencing the exact file with #file gives Copilot Chat the full function signature and dependencies. Specifying the test framework, naming convention, and what to mock prevents generic tests that need heavy editing.
Save this prompt to your library
Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.
Related prompts
Get thorough code reviews with actionable feedback tailored to your language, framework, and standards.
Context-Aware Code CompletionProviding the surrounding code and project context lets the model match existing patterns exactly. The constraint against modifying existing code prevents unwanted side effects.
Inline Code SuggestionConstraining suggestions to match existing style and scope produces insertions that feel native to the codebase. The 'no explanation' rule mimics real inline completion behavior.
Code ExplanationThe audience level parameter adjusts complexity automatically. Requiring a usage example ensures the explanation is practical, not just theoretical.