0.1.0 ā¢ Published 1 year ago
connect-web-mock-interceptor v0.1.0
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({ /* ... */ });
}),
]
});
0.1.0
1 year ago