Skip to content

Commit 36fbe40

Browse files
committed
Add README
1 parent 4f41456 commit 36fbe40

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Mirage-MSW
2+
3+
Experimental [MirageJS](https://miragejs.com/) interceptor using [MSW](https://mswjs.io/).
4+
5+
## Usage
6+
7+
### Installation
8+
9+
Pick one depending on your package manager:
10+
11+
```shell
12+
npm i --save-dev mirage-msw
13+
pnpm i --save-dev mirage-msw
14+
yarn add --dev mirage-msw
15+
```
16+
17+
If you are not already using MSW or Mirage, you will need to install those as well. Be sure to run [`msw init`](https://mswjs.io/docs/integrations/browser#copy-the-worker-script) as well.
18+
19+
We currently only support MSW v1, though we are exploring v2 support: https://github.com/miragejs/mirage-msw/pull/12
20+
21+
### Configuration
22+
23+
Wherever you are creating your miragejs server, set the interceptor:
24+
25+
```ts
26+
import MSWInterceptor from 'mirage-msw';
27+
import { createServer } from 'miragejs';
28+
29+
createServer({
30+
interceptor: new MSWInterceptor(),
31+
// ... rest of your config
32+
});
33+
```
34+
35+
This will cause msw to be used instead of the default interceptor, [pretender](https://github.com/pretenderjs/pretender).
36+
37+
## Caveats
38+
39+
This is very early, experimental software. There are probably a lot of bugs, so if you find one, please report it.
40+
41+
Here are the known issues so far:
42+
43+
- [ ] MSW starts up asynchronously, whereas Mirage up to now has always been completely synchronous. We will probably need to make a breaking change to Mirage to make `createServer` an async function.
44+
- [ ] Currently no support for FormData requests.
45+
- [ ] Only works in the browser, same as pretender. But MSW does have an option for node.js, so we may be able to support that in the future.

0 commit comments

Comments
 (0)