Chapter 10: Tests

Test

Also called Automated test

A small program that runs your code with a known input and checks the answer. If the answer is wrong it fails, loudly, without a person watching.

An agent can't see whether its work is right, but it can read a failure. A test is the cheapest way to turn "does this work?" into something it can act on in a loop.

Say it to your agent

“Write a test for total() in src/cart.test.ts that passes [200, 350] and expects 550, and one that passes [] and expects 0. Run bun test and show me the output.”

The workshop

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