Skip to content

Testing

Any provider or step is addressable by its token, so you can swap it for a test double at construction time — no monkey-patching, no module rewiring.

Pass overrides to createApp. Each key is a token; each value is either a plain object (wrapped as { token: value }) or a function runner:

const app = createApp({
modules: [ApiModule],
overrides: {
db: { find: () => ({ id: 'test-user' }) }, // plain object — wrapped as { db: value }
user: () => ({ user: { id: 'stub' } }), // function runner
},
});

Overrides replace only the named token’s runner; the rest of the graph is untouched. The route still runs its full closure — you’ve just substituted what one node produces.

This pairs well with app.explain(route) — explain the chain to see which tokens a route actually depends on, then override exactly those.