BoilerPrompt
Windsurf

Windsurf prompt to write unit tests

Instead of letting the agent dump assertions at random, this prompt makes Windsurf's Cascade read the module, propose a branch-by-branch test matrix, and only then write the suite. You get tests that match your existing runner and naming conventions, plus a coverage run that proves each branch was actually hit.

Last updated

Prompt
Write unit tests for the module I have open (or the path I give you). Start by reading the file and listing its public functions with the branches each one contains, then propose the test matrix before writing anything. Cover: normal inputs, boundary values (empty arrays, zero, max lengths), error paths that should throw or return failure objects, and any async rejection paths. Mock only true externals like network and clock, keep pure logic unmocked. Match the test runner already configured in this repo, follow its existing describe/it naming style, and put files next to the source or in the repo's test directory, whichever pattern already exists. Run the suite with coverage in the terminal, report uncovered lines, and add cases until each listed branch is hit. Do not modify the source under test to make testing easier without flagging it first.

Same task in other tools

Questions about this prompt

Cascade mocked pure functions it should have called directly. What now?

Reject those edits in the diff review and reply naming the functions: 'these are pure, remove the mocks and assert on real return values'. The prompt's mock-only-externals rule gives it the principle; the named list gives it the exact rewrite target.

Does this prompt work outside JavaScript?

Yes. The branch matrix, boundary values, and coverage loop are runner-agnostic, and Cascade detects pytest, go test, RSpec, or JUnit from the repo. Replace the describe/it phrasing with your runner's naming convention if it uses something else.

Coverage is high but some tests barely assert anything. What should I check?

Coverage measures execution, not verification, so a test can hit every line while asserting nothing. Ask Cascade to add a result or raised-error assertion to every test that lacks one, then rerun with coverage to confirm nothing regressed.

Related prompts