0.4.1 ā€¢ Published 1 year ago

msw-connect-web v0.4.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

msw-connect-web

Mock Service Worker utility for connect-web.

šŸš§ Streaming requests and responses are not currently supported.

šŸš§ And server-side mocking is currently not supported either. (Because MSW has no support for Node.js globalThis.fetch. mswjs/interceptors#283)

Usage

Install package.

npm i -D msw-connect-web msw

Define mocks.

handlers.ts

import { createMswConnectWeb } from 'msw-connect-web';
const connect = createMswConnectWeb({ baseUrl: 'https://...' });
export const handlers = [
  connect(YourService, 'methodName', async (req, res, ctx) => {
    // You can access the request message (with types) using the `message` method.
    const requestMessage = await req.message();
    return res(
      ctx.delay(1000),
      // You can define response with `message` method.
      ctx.message(new ResponseMessage({ ... })),
    );
  }),
];
0.4.1

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago