mockaton 8.7.1 → 8.7.2
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 +11 -11
- package/package.json +1 -1
- package/src/Dashboard.css +5 -0
- package/src/Dashboard.js +9 -3
package/README.md
CHANGED
|
@@ -5,27 +5,27 @@
|
|
|
5
5
|
|
|
6
6
|
## Mock your APIs, Enhance your Development Workflow
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Mockaton is an HTTP mock server with the goal of making
|
|
9
|
+
your frontend development and testing easier—and a lot more fun.
|
|
10
10
|
|
|
11
|
-
With Mockaton you don’t need to write code for wiring your mocks.
|
|
12
|
-
place your mocks in a directory and
|
|
13
|
-
|
|
11
|
+
With Mockaton you don’t need to write code for wiring your mocks.
|
|
12
|
+
Instead, just place your mocks in a directory, and it will scan it
|
|
13
|
+
for filenames that follow a convention similar to the URL paths.
|
|
14
14
|
|
|
15
15
|
For example, for this route `/api/user/1234`, the mock filename would be:
|
|
16
16
|
```
|
|
17
17
|
my-mocks-dir/api/user/[user-id].GET.200.json
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
## Scrapping Mocks from you Backend
|
|
21
|
+
|
|
22
|
+
Mockaton can fallback to your real backend on routes you don’t have mocks for. That’s
|
|
23
|
+
done by typing your backend address in the **Fallback Backend** field. And if you
|
|
24
|
+
check **Save Mocks**, you can collect those responses that hit your backend.
|
|
25
|
+
Those mocks will be saved to your `config.mocksDir` following the filename convention.
|
|
25
26
|
|
|
26
27
|
|
|
27
28
|
## Multiple Mock Variants
|
|
28
|
-
Here’s how you can create multiple mocks for a particular route:
|
|
29
29
|
|
|
30
30
|
### Adding comments in filenames
|
|
31
31
|
Want to mock a locked-out user or an invalid login attempt? You
|
package/package.json
CHANGED
package/src/Dashboard.css
CHANGED
package/src/Dashboard.js
CHANGED
|
@@ -16,13 +16,14 @@ const Strings = {
|
|
|
16
16
|
internal_server_error: 'Internal Server Error',
|
|
17
17
|
mock: 'Mock',
|
|
18
18
|
no_mocks_found: 'No mocks found',
|
|
19
|
+
pick: 'Pick…',
|
|
19
20
|
reset: 'Reset',
|
|
20
21
|
save_proxied: 'Save Mocks',
|
|
21
|
-
select_one: 'Select One',
|
|
22
22
|
static: 'Static'
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const CSS = {
|
|
26
|
+
BulkSelector: 'BulkSelector',
|
|
26
27
|
DelayToggler: 'DelayToggler',
|
|
27
28
|
FallbackBackend: 'FallbackBackend',
|
|
28
29
|
Field: 'Field',
|
|
@@ -115,19 +116,24 @@ function CookieSelector({ cookies }) {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
function BulkSelector({ comments }) {
|
|
119
|
+
// UX wise this should be a menu instead of this `select`.
|
|
120
|
+
// But this way is easier to implement, with a few hacks.
|
|
118
121
|
function onChange() {
|
|
119
|
-
|
|
122
|
+
const value = this.value
|
|
123
|
+
this.value = Strings.pick // Hack
|
|
124
|
+
mockaton.bulkSelectByComment(value)
|
|
120
125
|
.then(init)
|
|
121
126
|
.catch(onError)
|
|
122
127
|
}
|
|
123
128
|
const disabled = !comments.length
|
|
124
129
|
const list = disabled
|
|
125
130
|
? []
|
|
126
|
-
: [Strings.
|
|
131
|
+
: [Strings.pick].concat(comments)
|
|
127
132
|
return (
|
|
128
133
|
r('label', { className: CSS.Field },
|
|
129
134
|
r('span', null, Strings.bulk_select_by_comment),
|
|
130
135
|
r('select', {
|
|
136
|
+
className: CSS.BulkSelector,
|
|
131
137
|
'data-qaid': 'BulkSelector',
|
|
132
138
|
autocomplete: 'off',
|
|
133
139
|
disabled,
|