connect-web-mock-interceptor
v0.1.0
Published
Mock utility for connect-web
Downloads
2
Readme
connect-web-mock-interceptor
Mock utility for connect-web.
🚧 Streaming requests are not currently supported.
If you want to use with MSW, you can use msw-connect-web.
Usage
Install package.
npm i -D connect-web-mock-interceptor @bufbuild/protobuf
Define mocks.
handlers.ts
import { createConnectTransport } from '@bufbuild/connect-web';
import { mock } from 'connect-web-mock-interceptor';
const transport = createConnectTransport({
// ...
interceptors: process.env.USE_MOCKS !== 'true' ? [] : [
mock(YourService, "methodName", (req: RequestMessage) => {
// ...
return new ResponseMessage({ /* ... */ });
}),
]
});