What is the testing pyramid?

Answer

The testing pyramid (coined by Mike Cohn) is a model for organizing tests into layers based on speed, cost, and coverage: Base (Unit tests): the widest layer — fast, cheap, isolated, numerous. Should be the majority of your tests (70%). Middle (Integration tests): slower, test component interactions, fewer than unit tests (20%). Top (E2E/UI tests): slowest, most expensive, fewest — only critical scenarios (10%). The pyramid shape indicates the ideal ratio: many fast unit tests at the bottom, fewer integration tests in the middle, very few E2E tests at the top. Anti-pattern — Ice cream cone: mostly E2E tests and manual testing at top, few unit tests — inverted pyramid, expensive and fragile. Trophy model (Kent C. Dodds): emphasizes integration tests as the sweet spot, with unit tests for pure functions and few E2E tests. Regardless of shape, the principle holds: test at the lowest possible level for each concern.