mockaton 8.2.17 → 8.2.18
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 +16 -17
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|

|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
_Mockaton_ is a mock server for
|
|
7
|
+
_Mockaton_ is a mock server for improving the frontend development and testing experience.
|
|
8
8
|
|
|
9
9
|
With Mockaton, you don’t need to write code for wiring your mocks. Instead, it
|
|
10
10
|
scans a given directory for filenames following a convention similar to the
|
|
@@ -12,17 +12,26 @@ URL paths. For example, the following file will be served on `/api/user/1234`
|
|
|
12
12
|
```
|
|
13
13
|
my-mocks-dir/api/user/[user-id].GET.200.json
|
|
14
14
|
```
|
|
15
|
-
Also, you don’t need to mock everything. Mockaton can request from your backend
|
|
16
|
-
the routes you don’t have mocks for. See `Config.proxyFallback` below.
|
|
17
15
|
|
|
18
16
|
By the way, [this browser
|
|
19
17
|
extension](https://github.com/ericfortis/devtools-ext-tar-http-requests)
|
|
20
18
|
can create a TAR of your requests following that convention.
|
|
21
19
|
|
|
20
|
+
Nonetheless, you don’t need to mock all your APIs. Mockaton can request from your backend
|
|
21
|
+
the routes you don’t have mocks for. That’s done with `Config.proxyFallback = 'http://mybackend'`
|
|
22
|
+
|
|
23
|
+
## Multiple Mock Variants
|
|
24
|
+
Each route can have many mocks, which could either be:
|
|
25
|
+
- Different response __status code__. For example, for triggering errors.
|
|
26
|
+
- __Comment__ on the filename, which is anything within parentheses.
|
|
27
|
+
For example, `api/login(locked out user).POST.423.json`
|
|
28
|
+
|
|
29
|
+
|
|
22
30
|
## Dashboard UI
|
|
23
31
|
|
|
24
|
-
In the dashboard, you can
|
|
25
|
-
route.
|
|
32
|
+
In the dashboard, you can select a mock variant for a particular
|
|
33
|
+
route. On the other hand, they can be selected programmatically
|
|
34
|
+
for instance, for setting up tests (see **Commander API** below).
|
|
26
35
|
|
|
27
36
|
<picture>
|
|
28
37
|
<source media="(prefers-color-scheme: light)" srcset="./README-dashboard-light.png">
|
|
@@ -64,7 +73,7 @@ This demo uses the [sample-mocks/](./sample-mocks) directory of this repository.
|
|
|
64
73
|
|
|
65
74
|
Experiment with the Dashboard:
|
|
66
75
|
|
|
67
|
-
- Pick a mock variant from the _Mock dropdown_
|
|
76
|
+
- Pick a mock variant from the _Mock dropdown_
|
|
68
77
|
- Toggle the 🕓 _Delay Responses_ button, (e.g. for testing spinners)
|
|
69
78
|
- Toggle the _500_ button, which sends and _Internal Server Error_ on that endpoint
|
|
70
79
|
|
|
@@ -112,17 +121,7 @@ filename, such as `(demo-part1)`, `(demo-part2)`.
|
|
|
112
121
|
- [Mock Server Worker](https://mswjs.io)
|
|
113
122
|
|
|
114
123
|
---
|
|
115
|
-
|
|
116
|
-
## Multiple Mock Variants
|
|
117
|
-
Each route can have many mocks, which could either be:
|
|
118
|
-
- Different response __status code__. For example, for triggering errors.
|
|
119
|
-
- __Comment__ on the filename, which is anything within parentheses.
|
|
120
|
-
- e.g. `api/login(locked out user).POST.423.json`
|
|
121
|
-
|
|
122
|
-
Those alternatives can be manually selected on the dashboard, or
|
|
123
|
-
programmatically (see **Commander API** section), for instance, for setting up tests.
|
|
124
|
-
|
|
125
|
-
### Default Mock for a Route
|
|
124
|
+
## Default Mock for a Route
|
|
126
125
|
You can add the comment: `(default)` to a filename.
|
|
127
126
|
Otherwise, the first file in **alphabetical order** wins.
|
|
128
127
|
|
package/package.json
CHANGED