msw-fetch-mock 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +8 -13
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -20,17 +20,14 @@ npm install -D msw-fetch-mock msw
20
20
 
21
21
  ```typescript
22
22
  import { setupServer } from 'msw/node';
23
- import { createFetchMock } from 'msw-fetch-mock';
23
+ import { FetchMock } from 'msw-fetch-mock';
24
24
 
25
25
  const server = setupServer();
26
- const fetchMock = createFetchMock(server);
26
+ const fetchMock = new FetchMock(server);
27
27
 
28
28
  beforeAll(() => fetchMock.activate());
29
29
  afterAll(() => fetchMock.deactivate());
30
- afterEach(() => {
31
- fetchMock.clearCallHistory();
32
- fetchMock.assertNoPendingInterceptors();
33
- });
30
+ afterEach(() => fetchMock.assertNoPendingInterceptors());
34
31
 
35
32
  it('mocks a GET request', async () => {
36
33
  fetchMock
@@ -47,7 +44,7 @@ it('mocks a GET request', async () => {
47
44
 
48
45
  ## API Overview
49
46
 
50
- ### `createFetchMock(server?)`
47
+ ### `new FetchMock(server?)`
51
48
 
52
49
  Creates a `FetchMock` instance. Optionally accepts an existing MSW `SetupServer`; creates one internally if omitted.
53
50
 
@@ -64,12 +61,10 @@ fetchMock
64
61
  ### Call History
65
62
 
66
63
  ```typescript
67
- const history = fetchMock.getCallHistory();
68
- history.calls(); // all calls
69
- history.lastCall(); // most recent
70
- history.firstCall(); // earliest
71
- history.nthCall(2); // 2nd call (1-indexed)
72
- history.filterCalls({ method: 'POST', path: '/users' }, { operator: 'AND' });
64
+ fetchMock.calls.lastCall(); // most recent
65
+ fetchMock.calls.firstCall(); // earliest
66
+ fetchMock.calls.nthCall(2); // 2nd call (1-indexed)
67
+ fetchMock.calls.filterCalls({ method: 'POST', path: '/users' }, { operator: 'AND' });
73
68
  ```
74
69
 
75
70
  ### Assertions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw-fetch-mock",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Undici-style fetch mock API built on MSW (Mock Service Worker)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/recca0120/msw-fetch-mock.git"
16
+ "url": "git+https://github.com/recca0120/msw-fetch-mock.git"
17
17
  },
18
18
  "packageManager": "pnpm@10.12.4",
19
19
  "engines": {