Skip to content

Testing ​

Campfire is tested in two layers, each aimed at a different kind of failure. Unit tests prove the logic – the models, the converters that decode what the back-end sends, the session client, the role helpers – in all three languages. Walk-throughs prove the screens, by driving the real web application in a real browser and each shell on a device, because a screen is mostly composition and its failures only show when the whole thing runs (ADR 024).

Underneath both is the mock back-end, a stand-in for the real services that answers as they do. The walk-throughs sign in and read the list of participants through it, so no test reaches a back-end, needs credentials, or touches a real person's data (ADR 021). The one request that leaves the machine is a unit's map asking OpenFreeMap for its background, which a walk lets through but does not depend on (ADR 037).

The chapter is in three parts:

PartWhat it covers
The mock back-endThe stand-in for the back-end that local work and the walk-throughs run on
Unit testsVitest for the TypeScript, and each shell's own tools for its language
UI testsA Playwright walk-through per module, and a launch walk through each shell

Tests live beside the code they cover rather than in a parallel tree – string.test.ts next to string.ts, a module's walk-throughs in its own test-ui/ – and they are written with that code, so a package lands with the tests that prove it. The formatters, linters, and type checks are not tests and are covered in The checks. What runs on a pull request is in Continuous integration.

What runs what ​

CommandWhat it runs
pnpm testEvery TypeScript unit test, through Vitest, with the coverage ratchet
pnpm test:web:uiThe Playwright walk-throughs, one project per module, against the local mock
pnpm test:appleThe Apple unit tests on a Simulator, and a compile of the Apple walk
pnpm test:apple:uiThe Apple walk, driving the real shell on a Simulator
pnpm test:androidThe Android unit tests on the JVM, and a compile of the Android walk
pnpm test:android:uiThe Android walk, on an emulator the script boots

The known gaps ​

  • Nothing renders React in a unit test. Components are proved in Storybook and by the walk-throughs instead, because a render in a fake DOM skips the routing and registration where a screen's failures live (ADR 024).
  • The interactive back swipe is checked by hand on both shells, because no walk can synthesize the edge gesture.
  • Nothing checks the bridge across languages. Each side is written against the one contract in ADR 018 and tested on its own, and a decoder that agrees with the encoder beside it proves nothing about the other side.
  • Nothing checks the mock against the real services. It copies them by hand, so a change in a service reaches the mock only when someone copies it (ADR 021).