@decoyhq/testplane
v0.4.0
Published
Testplane plugin for the native Decoy runtime.
Readme
@decoyhq/testplane
Testplane plugin for the native decoy runtime.
npm i -D @decoyhq/cli @decoyhq/testplane// .testplane.conf.ts
export default {
plugins: {
'@decoyhq/testplane': {
url: 'http://127.0.0.1:8080',
command: 'decoy serve',
urls: '**/api/**', // browser requests sent to Decoy
collection: 'happy-path', // each test's Session starts here
},
},
} satisfies ConfigInput
// some.testplane.ts
import { decoy } from '@decoyhq/testplane'
it('empty state', async ({ browser }) => {
await decoy(browser).useCollection('empty')
await decoy(browser).useRoute('users-by-id:user-123:missing') // or ('users-by-id', 'user-123', 'missing')
await decoy(browser).reset()
})- The master process starts
commandonRUNNER_STARTunless Decoy already answersGET /__decoy__/healthaturl(reuse allowed locally, refused whenCIis set), and stops it onRUNNER_ENDonly if it started it. - Each test gets its own Session: a root
beforeEachchecks Decoy's health, appliescollection, and a rootafterEachends the Session.decoy(browser)is that Session's Router. - With
urls, matching requests from every page of the test's browser go to Decoy withx-mock-sessionset. Chrome rewrites the request URL itself (CDPFetch.continueRequest), so method, headers, and body are kept and the page sees its own origin. If Decoy is unreachable the request fails; it never reaches the real network. Requests between tests are aborted. - Chrome/Chromium only for now (CDP through
browser.getPuppeteer()), in WebDriver Classic and BiDi (webSocketUrl: true) sessions. Withurlson another browser, each test fails with a clear error.
