Switch responses in a test
Use decoy(browser) 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.testplane.ts
Session lifecycle
- Before tests run, the plugin starts
commandunless Decoy already answers health. When the run ends it stops only what it started. - Each test gets a Session id (
<browser>-<full title>-<uuid>). Before the test and its hooks (including a file's top-levelbeforeEach), Decoy's health is checked andcollectionapplied. After the test and itsafterEachhooks, the Session ends. - Browser requests matching
urls, from every tab, popup, cross-site iframe, and worker (dedicated, shared, service), go to Decoy with method, path and query, headers, cookies, and body kept, andx-mock-sessionset. Chrome rewrites the URL itself, so the page sees its own origin (no CORS). Decoy's answer, including a 501 miss, reaches the page as-is; a redirect's relativeLocationresolves against the page's URL, not Decoy's. If Decoy is unreachable the request fails, never sent to the real network. New tabs stay paused until routing is on, so even their first request is covered. Matching requests fired between tests are aborted. decoy(browser):sessionId,useCollection(id),useRoute(address)with a Behavior addressroute:case:behavior(oruseRoute(route, case, behavior)),reset(),endSession(). Each call hits the Control API immediately and rejects with Decoy's error. It throws outside a test.