connect-web-mock-interceptor
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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({ /* ... */ });
    }),
  ]
});

Readme

Keywords

Package Sidebar

Install

npm i connect-web-mock-interceptor

Weekly Downloads

0

Version

0.1.0

License

Apache-2.0

Unpacked Size

18.3 kB

Total Files

7

Last publish

Collaborators

  • ssssota