Skip to content

Mocking

Mock your oRPC handlers with ease.

WARNING

This page is incomplete and may be missing important information.

Using the Implementer

The Implementer is designed for contract-first development. However, it can also be used to create alternative versions of your router or procedure for testing purposes.

ts
import { 
implement
,
unlazyRouter
} from '@orpc/server'
const
fakeListPlanet
=
implement
(
router
.
planet
.
list
).
handler
(() => [])

You can now use fakeListPlanet to replace listPlanet. Additionally, the implement function can be used to create a fake server for front-end testing.

WARNING

The implement function does not support the lazy router yet. Please use the unlazyRouter utility to convert your lazy router before implementing.

Released under the MIT License.