0.0.4 • Published 11 months ago

cy-trpc v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Installation

ni -D cy-trpc
# pnpm
pnpm add -D cy-trpc
# yarn
yarn add -D cy-trpc
# npm
npm i -D cy-trpc

No need to run a server

Define your router

const t = initTRPC.create({ allowOutsideOfServer: true })
const router = t.router({
  hello: t.procedure.query(() => 'world'),
})

Create the stub

const trpcStub = stubTRPC<Router>()

trpcStub.hello.returns('interceptor')

Test it!

const client = createTRPCProxyClient<Router>({
  links: [httpLink({ url: '/api/trpc' })],
})

const result = await client.hello.query()
expect(result).equal('interceptor')

Unstable!

For now, having a intercept is enough for my use case. But I am still figuring out how to make it generic as possible and support several use cases for mocking/stubbing tRPC.

Things on the roadmap:

  • Support tRPC config
    • transformer solved in 0.0.4
    • base url
    • links
  • Pass options to cy.intercept
  • Mock tRPC client
0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago