Switch responses in a test
Use the decoy fixture to select a Collection before the page makes its request. This test selects no-users and checks the error that the page renders.
tests/users.spec.ts
Session lifecycle
setup(global setup) startscommandunless Decoy already answers health. Its teardown stops only what it started. Fixtures never start Decoy.- Each test gets a Session id (
<file>-<title>-<uuid>). Before routing or test code runs, Decoy's health is checked andcollectionapplied. - Browser requests matching
urlsgo to Decoy with method, path and query, headers, and body kept, andx-mock-sessionset. Decoy's answer, including a 501 miss, reaches the page as-is. If Decoy is unreachable the request is aborted, never sent to the real network. - The
decoyfixture:sessionId,useCollection(id),useRoute(address)with a Behavior addressroute:case:behavior(oruseRoute(route, case, behavior)),reset(),endSession(), andconnection(route)(see WebSockets). Each call hits the Control API immediately and rejects with Decoy's error. When the test ends, the fixtures callendSession()for you, so a long-lived Decoy doesn't keep one Session per test.