mockaton 9.1.1 → 9.2.0
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 +22 -11
- package/lcov.info +780 -774
- package/package.json +1 -1
- package/src/Api.js +2 -1
- package/src/ApiConstants.js +2 -1
- package/src/Dashboard.js +19 -19
- package/src/MockDispatcher.js +3 -6
- package/src/Mockaton.js +2 -19
- package/src/cli.js +34 -16
- package/src/config.js +8 -13
- package/src/utils/http-response.js +1 -1
package/README.md
CHANGED
|
@@ -94,9 +94,9 @@ api/videos.GET.<b>500</b>.txt # Internal Server Error
|
|
|
94
94
|
## Scraping Mocks from your Backend
|
|
95
95
|
|
|
96
96
|
### Option 1: Browser Extension
|
|
97
|
-
|
|
97
|
+
The companion Chrome [devtools
|
|
98
98
|
extension](https://github.com/ericfortis/download-http-requests-browser-ext)
|
|
99
|
-
you
|
|
99
|
+
lets you download all the HTTP responses, and they
|
|
100
100
|
get saved following Mockaton’s filename convention.
|
|
101
101
|
|
|
102
102
|
### Option 2: Fallback to Your Backend
|
|
@@ -123,7 +123,7 @@ They will be saved in your `config.mocksDir` following the filename convention.
|
|
|
123
123
|
- Does not write to disk. Except when you select ✅ **Save Mocks** for scraping mocks from a backend.
|
|
124
124
|
- Does not initiate network connections (no logs, no telemetry).
|
|
125
125
|
- Does not hijack your HTTP client.
|
|
126
|
-
- Auditable. Organized and small — under 4 KLoC (
|
|
126
|
+
- Auditable. Organized and small — under 4 KLoC (half is UI and tests).
|
|
127
127
|
|
|
128
128
|
|
|
129
129
|
## Basic Usage
|
|
@@ -131,21 +131,28 @@ They will be saved in your `config.mocksDir` following the filename convention.
|
|
|
131
131
|
|
|
132
132
|
2. Create a sample mock in the default mocks directory (`./mockaton-mocks`)
|
|
133
133
|
```sh
|
|
134
|
-
mkdir -p
|
|
134
|
+
mkdir -p mockaton-mocks/api
|
|
135
135
|
echo "[1,2,3]" > mockaton-mocks/api/foo.GET.200.json
|
|
136
136
|
```
|
|
137
|
-
3. Run Mockaton (npx installs it if needed)
|
|
137
|
+
3. Run Mockaton (`npx` installs it if needed)
|
|
138
138
|
```shell
|
|
139
139
|
npx mockaton --port 2345
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
+
4. Test it
|
|
143
|
+
```shell
|
|
144
|
+
curl http://localhost:2345/api/foo
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Alternative Installations
|
|
142
148
|
<details>
|
|
143
|
-
<summary>
|
|
149
|
+
<summary>With NPM…</summary>
|
|
144
150
|
|
|
145
151
|
```shell
|
|
146
152
|
npm install mockaton --save-dev
|
|
147
153
|
```
|
|
148
154
|
|
|
155
|
+
Then in your, `package.json`:
|
|
149
156
|
```json
|
|
150
157
|
{
|
|
151
158
|
"scripts": {
|
|
@@ -157,17 +164,19 @@ npm install mockaton --save-dev
|
|
|
157
164
|
|
|
158
165
|
|
|
159
166
|
<details>
|
|
160
|
-
<summary>
|
|
167
|
+
<summary>Without NPM…</summary>
|
|
168
|
+
|
|
169
|
+
Since Mockaton has no dependencies, you can create an executable
|
|
170
|
+
by linking to `src/cli.js`.
|
|
161
171
|
|
|
162
|
-
Clone this repo, and make a link to `src/cli.js`
|
|
163
172
|
```shell
|
|
164
173
|
git clone https://github.com/ericfortis/mockaton.git
|
|
165
174
|
ln -s `realpath mockaton/src/cli.js` ~/bin/mockaton # some dir in your $PATH
|
|
166
175
|
```
|
|
167
176
|
|
|
168
|
-
|
|
169
177
|
</details>
|
|
170
178
|
|
|
179
|
+
<br/>
|
|
171
180
|
|
|
172
181
|
|
|
173
182
|
## CLI Options
|
|
@@ -484,15 +493,17 @@ Defaults to `'normal'`.
|
|
|
484
493
|
<details>
|
|
485
494
|
<summary>Programmatic Launch (Optional)</summary>
|
|
486
495
|
|
|
496
|
+
|
|
487
497
|
```js
|
|
488
498
|
import { Mockaton } from 'mockaton'
|
|
489
499
|
import mockatonConfig from './mockaton.config.js'
|
|
490
500
|
|
|
491
|
-
Mockaton({
|
|
501
|
+
const server = Mockaton({
|
|
492
502
|
...mockatonConfig, // Not required, but it’s not read by default.
|
|
493
|
-
port: 3333, // etc.
|
|
494
503
|
})
|
|
495
504
|
```
|
|
505
|
+
See [src/cli.js](src/cli.js)
|
|
506
|
+
|
|
496
507
|
</details>
|
|
497
508
|
|
|
498
509
|
|