intermediate · 24 minute study
Choose the test that can actually prove the claim
One green test is not evidence for every layer of a feature. The right test reaches the boundary where the claimed behavior is enforced.
Useful preparation · 1 prerequisite
Use this as a map, not a lock. If these ideas are familiar, continue.
- Make one hypothesis face a counterexample — Changing several things until a bug disappears can leave you unable to explain the fix or prevent the failure from returning.
First, build a mental model
A test surrounds a contract with controlled inputs and observable outputs. Its authority ends at the boundaries it replaces with mocks.
- Unit tests isolate small logic contracts. Integration tests exercise cooperating components such as a data adapter and database. E2E tests follow user-visible flows through the deployed-style application.
- A mock is a controlled substitute, not evidence that the substituted system behaves as imagined. Use it to isolate a question and document the boundary it removes.
- Fixtures should be small, named and isolated. Include missing, malformed, boundary and unauthorized cases that could falsify the claim.
- Coverage reports tell you which code ran, not whether assertions detected wrong behavior. A test pyramid is a cost/feedback guide, not a quota to satisfy blindly.
import test from 'node:test';
import assert from 'node:assert/strict';
test('one toy order line totals integer cents', () => {
const total = 125 * 2;
assert.equal(total, 250);
});
// This proves the stated arithmetic only, not RLS or persistence.- Claim
The example checks one calculation and an independent expected value.
- Boundary
No HTTP request, database policy or browser interaction was exercised.
- Next proof
If the claim is 'unauthorized orders cannot be saved', choose a test that reaches the real write authority.
Production thinking
Take this beyond the example.
Test the smallest boundary that can prove each consequential claim. Reserve expensive E2E work for integration/user risks that smaller tests cannot establish; do not replace security integration proof with a mock.
Sources and further reading
Your evidence
unseen is a local learning signal, not a credential or proof of production competence.
Explain the mental model, then explicitly acknowledge it. Opening a page is not evidence.
Supported retries can complete this lesson. Independent evidence and delayed review determine the skill stage.
Next lesson · Make verification reproducible and honest →