Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/varugasu/cy-trpc
A dynamic Cypress Interceptor for tRPC routers
https://github.com/varugasu/cy-trpc
cypress trpc
Last synced: 3 months ago
JSON representation
A dynamic Cypress Interceptor for tRPC routers
- Host: GitHub
- URL: https://github.com/varugasu/cy-trpc
- Owner: varugasu
- License: mit
- Created: 2023-06-17T13:10:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-06-18T14:15:09.000Z (over 1 year ago)
- Last Synced: 2024-10-30T01:09:14.546Z (3 months ago)
- Topics: cypress, trpc
- Language: TypeScript
- Homepage:
- Size: 178 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## 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
```ts
const t = initTRPC.create({ allowOutsideOfServer: true })
const router = t.router({
hello: t.procedure.query(() => 'world'),
})
```### Create the stub
```ts
const trpcStub = stubTRPC()trpcStub.hello.returns('interceptor')
```### Test it!
```ts
const client = createTRPCProxyClient({
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