spy
spy<T>(): SpyAdapter<T>
Records all exchanges passing through it. Use as a destination (.to() / .tap(), void send), enricher (.enrich(); the fetch face returns the current body, so a bare .enrich(spy()) observes without changing it), or processor to capture and assert on pipeline output.
import { spy } from '@routecraft/testing'
const spyAdapter = spy()
const route = craft()
.id('my-route')
.from(simple('payload'))
.to(spyAdapter)
const t = await testContext().routes(route).build()
await t.test()
expect(spyAdapter.received).toHaveLength(1)
expect(spyAdapter.received[0].body).toBe('payload')
expect(spyAdapter.calls.send).toBe(1)
Properties:
Methods:
See Testing for full usage patterns.