Chapter 10: Tests

Test pyramid

A rule of thumb for the mix: many fast unit tests at the bottom, fewer integration tests in the middle, and very few slow end-to-end tests on top.

An agent runs your tests over and over in a loop, so slow tests cost you on every attempt. It is cheap for an agent to write a slow test now. Waiting for it, and working out why it flaked, is still expensive.

Say it to your agent

“The whole suite takes 9 minutes because everything goes through the browser. Keep the 5 most important journeys as Playwright tests, and rewrite the others as unit or integration tests. Target under 60 seconds in total.”

The workshop

Name a word, or describe what you mean in everyday language.