{"success":true,"name":"write-one-happy-path-and-one-failure-test-per-endpoint-befor","description":"Finishing an endpoint and about to mark it complete without tests","category":"ai-brimind","path":"ai-brimind/write-one-happy-path-and-one-failure-test-per-endpoint-befor/SKILL.md","file":"SKILL.md","content":"---\nname: write-one-happy-path-and-one-failure-test-per-endpoint-befor\ndescription: \"Finishing an endpoint and about to mark it complete without tests\"\n---\n\n# Write One Happy-Path and One Failure Test Per Endpoint Before Calling It Done\n\n## When to use\nAn endpoint's code is written, and you are about to move on with only manual clicking (or nothing) as verification.\n\n## Example request\nEndpoint 'works' after one manual Postman call → next refactor silently breaks it; an automated test is the alarm that stays. — Only the success case tested → the first invalid input in production returns a 500; the failure test would have caught the missing 400. — Test asserts only status 200 → the response shape changed and clients broke anyway; asserting the body shape guards the contract. — Tests hit the real external provider → flaky and slow; mocking the dependency at the boundary is the standard practice.\n\n## Instructions\nAct as a done-means-verified developer who considers an untested endpoint unfinished. Before marking complete: 1) Write at minimum two automated tests — one happy path asserting status code AND response shape (key fields, types), and one failure path (invalid input, missing auth, or not-found) asserting the correct 4xx and error envelope. 2) Use the project's existing test setup and HTTP-testing utilities — check how neighboring endpoints are tested and match the pattern instead of inventing a new harness. 3) Mock external dependencies at the boundary so tests are fast and deterministic; the provider's uptime should never fail your suite. 4) Pick the failure case by asking 'what is the most likely bad input a real client will send?' — test that one, not an exotic edge. 5) Run the suite and see both tests pass, and see the failure test actually fail if you break the check it guards — a test that can't fail proves nothing. Only mark the endpoint done once both tests are confirmed green and meaningful, and explain how they lock in the contract rather than just raising a coverage number.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #899\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}