mockaton 8.1.4 → 8.1.6
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.
- package/README.md +13 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ By the way, [this browser
|
|
|
12
12
|
extension](https://github.com/ericfortis/devtools-ext-tar-http-requests)
|
|
13
13
|
can create a TAR of your XHR requests following that convention.
|
|
14
14
|
|
|
15
|
+
### Dashboard Example
|
|
15
16
|
|
|
16
17
|
<picture>
|
|
17
18
|
<source media="(prefers-color-scheme: light)" srcset="./README-dashboard-light.png">
|
|
@@ -44,7 +45,7 @@ node --import=tsx my-mockaton.js
|
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
|
|
47
|
-
## Running the Example
|
|
48
|
+
## Running the Example
|
|
48
49
|
This demo uses the [sample-mocks/](./sample-mocks) directory of this repository.
|
|
49
50
|
|
|
50
51
|
- Checkout this repo
|
|
@@ -57,8 +58,8 @@ Experiment with the Dashboard:
|
|
|
57
58
|
|
|
58
59
|
- Pick a mock variant from the Mock dropdown (we’ll discuss
|
|
59
60
|
them later)
|
|
60
|
-
- Toggle the
|
|
61
|
-
- Toggle _500_ button, which sends and _Internal Server Error_ on that endpoint
|
|
61
|
+
- Toggle the 🕓 Clock button, which _Delays_ responses (e.g. for testing spinners)
|
|
62
|
+
- Toggle the _500_ button, which sends and _Internal Server Error_ on that endpoint
|
|
62
63
|
|
|
63
64
|
Finally, edit a mock file. You don’t need to restart Mockaton for that. The
|
|
64
65
|
_Reset_ button is for registering newly added, removed, or renamed mocks.
|
|
@@ -92,10 +93,10 @@ _Reset_ button is for registering newly added, removed, or renamed mocks.
|
|
|
92
93
|
Each route can have many mocks, which could either be:
|
|
93
94
|
- Different response __status code__. For example, for testing error responses.
|
|
94
95
|
- __Comment__ on the filename, which is anything within parentheses.
|
|
95
|
-
- e.g. `api/user
|
|
96
|
+
- e.g. `api/login(locked out user).POST.423.json`
|
|
96
97
|
|
|
97
|
-
Those alternatives can be manually selected
|
|
98
|
-
|
|
98
|
+
Those alternatives can be manually selected on the dashboard, or
|
|
99
|
+
programmatically (see **Commander API** section), for instance, for setting up tests.
|
|
99
100
|
|
|
100
101
|
### Default Mock for a Route
|
|
101
102
|
You can add the comment: `(default)` to a filename.
|
|
@@ -215,8 +216,7 @@ Defaults to `/(\.DS_Store|~)$/`
|
|
|
215
216
|
|
|
216
217
|
|
|
217
218
|
### `delay?: number` 🕓
|
|
218
|
-
The clock icon next to the mock selector is a checkbox for delaying a
|
|
219
|
-
particular response. They are handy for testing spinners.
|
|
219
|
+
The clock icon next to the mock selector is a checkbox for delaying a particular response.
|
|
220
220
|
|
|
221
221
|
The delay is globally configurable via `Config.delay = 1200` (milliseconds).
|
|
222
222
|
|
|
@@ -228,7 +228,7 @@ For example, `Config.proxyFallback = 'http://example.com:8080'`
|
|
|
228
228
|
|
|
229
229
|
### `staticDir?: string`
|
|
230
230
|
Files under `Config.staticDir` don’t use the filename convention.
|
|
231
|
-
Also, they take precedence over the `GET` mocks in `Config.
|
|
231
|
+
Also, they take precedence over the `GET` mocks in `Config.mocksDir`.
|
|
232
232
|
|
|
233
233
|
For example, if you have two files for `GET /foo/bar.jpg`
|
|
234
234
|
```
|
|
@@ -249,8 +249,8 @@ The key is just a label used for selecting a particular cookie in the
|
|
|
249
249
|
dashboard. In the dashboard, only one cookie can be selected. If you need
|
|
250
250
|
more cookies you can inject additional cookies globally in `Config.extraHeaders`.
|
|
251
251
|
|
|
252
|
-
`jwtCookie` has a hardcoded header and
|
|
253
|
-
words, it’s useful if you only care about its payload.
|
|
252
|
+
By the way, there’s a `jwtCookie` helper, which has a hardcoded header and
|
|
253
|
+
signature. In other words, it’s useful if you only care about its payload.
|
|
254
254
|
|
|
255
255
|
```js
|
|
256
256
|
import { jwtCookie } from 'mockaton'
|
|
@@ -280,7 +280,7 @@ Config.extraHeaders = [
|
|
|
280
280
|
### `extraMimes?: { [fileExt: string]: string }`
|
|
281
281
|
```js
|
|
282
282
|
Config.extraMimes = {
|
|
283
|
-
|
|
283
|
+
jpe: 'application/jpeg'
|
|
284
284
|
}
|
|
285
285
|
```
|
|
286
286
|
|
|
@@ -364,7 +364,7 @@ Config.onReady = open
|
|
|
364
364
|
|
|
365
365
|
---
|
|
366
366
|
|
|
367
|
-
##
|
|
367
|
+
## Commander API
|
|
368
368
|
`Commander` is a wrapper for the Mockaton HTTP API.
|
|
369
369
|
All of its methods return their `fetch` response promise.
|
|
370
370
|
```js
|
package/package.json
CHANGED