Lesson 24 of 30
Not every test should be the same kind — the pyramid shape is a deliberate ratio: many fast, narrow unit tests at the base, fewer slow, broad end-to-end tests at the top.
13 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 2
A team's test suite is mostly E2E tests, with very few unit tests. What's the likely real-world consequence?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
The testing pyramid describes a healthy ratio of test types, not a strict hierarchy of importance:
// E2E, with Playwright — drives a real browser
test("user can complete checkout", async ({ page }) => {
await page.goto("/products/42");
await page.click("text=Add to cart");
await page.click("text=Checkout");
await page.fill("[name=card]", "4242424242424242");
await page.click("text=Place order");
await expect(page.locator("text=Order confirmed")).toBeVisible();
});
Unit tests: many, fast, cheap — test one function in isolation.
"How would you decide what to unit test versus E2E test for a checkout flow?" is a practical, common question — a strong answer explains the pyramid's ratio reasoning (speed, cost, flakiness) rather than just naming the three test types.