Course 13 · Craft

Testing
Proof that it still works.

Write the runner, then use it: assertions, doubles, fake time, async, the DOM, flakiness and what coverage will never tell you.

16Lessons
≈ 3hReading
16Playable now
UnitDoublesAsyncDOMFlakyCI

0 of 16 lessons finished — nothing yet

The syllabus

16 lessons,
in the order they build on each other.

Start lesson one ↗
01

What a test buys you

The four things tests are actually for, and the ones that are not worth writing.

≈ 11 min
02

Write the runner

A test is a function that throws. Build describe, it and expect in forty lines.

≈ 13 min
03

Assertions

Identity against equality, deep comparison, errors, and a failure message worth reading.

≈ 12 min
04

The shape of a test

Arrange, act, assert — one reason to fail, and a name that says what broke.

≈ 12 min
05

What to test

Behaviour, not implementation: the difference between a test that helps and one that blocks every refactor.

≈ 13 min
06

Test doubles

Stub, spy, mock, fake — four different things, and when each one is right.

≈ 13 min
07

Time and randomness

Fake timers, an injected clock and a seeded generator: making the unpredictable exact.

≈ 12 min
08

Asynchronous tests

Awaiting properly, testing rejection, and the test that passes because it never ran.

≈ 12 min
09

Integration tests

Where the real database and the real HTTP layer earn their cost — and how to keep them fast.

≈ 13 min
10

Testing the interface

Query the way a user finds things: by role and by name, not by class name.

≈ 13 min
11

End to end

What only a browser can prove, how many of those you want, and the ones worth having.

≈ 12 min
12

Flaky tests

The five causes, the fixes, and why a retry is a decision and not a solution.

≈ 12 min
13

Coverage, honestly

What the percentage measures, what it cannot, and the mutation that proves a test is real.

≈ 12 min
14

Test first

Red, green, refactor — where it genuinely helps and where it gets in the way.

≈ 12 min
15

Tests in the pipeline

Fast, parallel, deterministic — and what to do with the one that fails twice a week.

≈ 12 min
16

Practice: catch a real bug

A function with three bugs in it. Write the tests that find them, then fix it.

≈ 15 min