Skip to the workspace
Pebellslearn by building
Collaboration  ›  Lesson

Unit, Integration and E2E Tests

Unit Testing 14 minUnit tests check one piece, integration tests check the joins between pieces and end-to-end tests check a whole user journey; in an AI product most of them fake the model, and each must be shown able to fail.

ai product builder / Unit, Integration and E2E Tests

Explore each scene at your own pace.

01 · The rule

The rule

Unit, Integration and E2E Tests

Every time Asha's assistant changes Pantry Pal, something might break far from the change. She cannot click through every screen after every edit. Automated tests do the clicking for her, but each kind catches a different sort of bug.

The rule

Unit tests check a piece, integration tests the joins, end-to-end the whole journey.

  • Unit test — one small piece on its own, such as a single function. Fast and precise: when it fails, you know exactly what broke.
  • Integration test — several pieces working together, such as a server route and the database. It catches bugs at the joins: mismatched field names, missing data, broken wiring.
  • End-to-end (E2E) test — a scripted browser acts like a user in the real app. It proves a whole journey works, but it is slower and breaks more easily when the design changes.

The usual balance is a pyramid: many unit tests, fewer integration tests, and a handful of E2E tests for the journeys that must never break.

test("removes dishes that contain an allergen", () => {
  const dishes = [{ name: "Satay noodles", ingredients: ["noodles", "peanuts"] }];
  expect(removeAllergens(dishes, ["peanuts"])).toEqual([]);
});

Two rules matter for an AI product:

  • Fake the model in most tests. Real model calls are slow, cost money and give different answers each time. Unit and integration tests use a stand-in that returns a fixed answer; the quality of real answers is the eval set's job.
  • Make sure each test can fail. Assistants sometimes write tests that pass whatever the code does. Break the code on purpose once. If the test still passes, it tests nothing.

You do not have to write tests by hand to benefit from them. Ask the assistant to add them with each slice, then read the test names: they should read like your acceptance checks.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.