{"success":true,"name":"choose-the-test-level-deliberately-unit-integration-or-end-t","description":"About to write tests and unsure what kind to write","category":"ai-brimind","path":"ai-brimind/choose-the-test-level-deliberately-unit-integration-or-end-t/SKILL.md","file":"SKILL.md","content":"---\nname: choose-the-test-level-deliberately-unit-integration-or-end-t\ndescription: \"About to write tests and unsure what kind to write\"\n---\n\n# Choose the Test Level Deliberately: Unit, Integration, or End-to-End\n\n## When to use\nYou're adding tests for a feature or module, and haven't consciously chosen which level (unit, integration, end-to-end) fits what you're protecting.\n\n## Example request\nPure calculation tested through the whole UI → slow, flaky, and one browser hiccup fails it; a unit test covers logic best. — Route handler unit-tested with everything mocked → all mocks pass, real DB call fails in production; the wiring needed an integration test. — Fifty end-to-end tests for every field → suite takes 40 minutes and everyone skips it; the test pyramid exists to keep feedback fast. — Bug was 'button did nothing after login' → no unit test could see it; one end-to-end test of the critical journey is the right guard.\n\n## Instructions\nAct as an inspector who picks the cheapest test that can actually catch the failure you fear. Before writing tests: 1) Name what you're protecting: pure logic and calculations → unit tests, fast and precise; the wiring between your layers (route → service → DB) → integration tests; the user's critical journey (login, pay, save) → a few end-to-end tests. 2) State the failure you fear in one sentence and check the chosen level can even see it — a unit test cannot catch broken wiring, an end-to-end test is a wasteful way to check math. 3) Respect the pyramid shape: many cheap unit tests, some integration tests, few end-to-end tests — invert it and the suite becomes slow and flaky and gets ignored. 4) Use the test tools the framework already provides before adding new tooling. 5) A test that fails randomly is worse than none — if a level keeps producing flaky tests, that's a signal you picked too high a level for the job. If you can't name what failure a test would catch, don't write it yet — investigate what actually breaks in this area first. Only commit to a level once the feared failure is confirmed visible at that level, and explain why this level catches the real risk instead of just adding coverage numbers.\n\n## Metadata\n- role: tester\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #962\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}