mockaton 10.0.0 → 10.1.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 +6 -6
- package/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/Dashboard.css +8 -3
- package/src/Dashboard.js +53 -32
- package/CHANGELOG.md +0 -115
- package/lcov.info +0 -2624
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ An HTTP mock server for simulating APIs with minimal setup
|
|
|
15
15
|
## Motivation
|
|
16
16
|
|
|
17
17
|
**No API state should be too hard to test.**
|
|
18
|
-
With Mockaton, developers can achieve correctness and
|
|
18
|
+
With Mockaton, developers can achieve correctness and speed.
|
|
19
19
|
|
|
20
20
|
### Correctness
|
|
21
21
|
- Enables testing of complex scenarios that would otherwise be skipped. e.g.,
|
|
@@ -60,9 +60,9 @@ Nonetheless, there’s a programmatic API, which is handy
|
|
|
60
60
|
for setting up tests (see **Commander API** section below).
|
|
61
61
|
|
|
62
62
|
<picture>
|
|
63
|
-
<source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.
|
|
64
|
-
<source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.
|
|
65
|
-
<img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.
|
|
63
|
+
<source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.vp781x772.light.gold.png">
|
|
64
|
+
<source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.vp781x772.dark.gold.png">
|
|
65
|
+
<img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.vp781x772.light.gold.png">
|
|
66
66
|
</picture>
|
|
67
67
|
|
|
68
68
|
|
|
@@ -174,7 +174,7 @@ Since Mockaton has no dependencies, you can create an executable
|
|
|
174
174
|
by linking to `src/cli.js`.
|
|
175
175
|
|
|
176
176
|
```shell
|
|
177
|
-
git clone https://github.com/ericfortis/mockaton.git
|
|
177
|
+
git clone https://github.com/ericfortis/mockaton.git --depth 1
|
|
178
178
|
ln -s `realpath mockaton/src/cli.js` ~/bin/mockaton # some dir in your $PATH
|
|
179
179
|
```
|
|
180
180
|
|
|
@@ -516,7 +516,7 @@ const server = await Mockaton(
|
|
|
516
516
|
## Demo App (Vite + React)
|
|
517
517
|
|
|
518
518
|
```sh
|
|
519
|
-
git clone https://github.com/ericfortis/mockaton.git
|
|
519
|
+
git clone https://github.com/ericfortis/mockaton.git --depth 1
|
|
520
520
|
cd mockaton/demo-app-vite
|
|
521
521
|
npm install
|
|
522
522
|
|
package/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ interface Config {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
export function Mockaton(options: Partial<Config>): Server | undefined
|
|
48
|
+
export function Mockaton(options: Partial<Config>): Promise<Server | undefined>
|
|
49
49
|
export function defineConfig(options: Partial<Config>): Partial<Config>
|
|
50
50
|
|
|
51
51
|
export const jsToJsonPlugin: Plugin
|
package/package.json
CHANGED
package/src/Dashboard.css
CHANGED
|
@@ -157,7 +157,7 @@ header {
|
|
|
157
157
|
align-items: flex-end;
|
|
158
158
|
gap: 16px 10px;
|
|
159
159
|
|
|
160
|
-
@media (max-width:
|
|
160
|
+
@media (max-width: 780px) {
|
|
161
161
|
max-width: 400px;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -315,7 +315,7 @@ main {
|
|
|
315
315
|
min-width: 0;
|
|
316
316
|
min-height: 0;
|
|
317
317
|
|
|
318
|
-
@media (max-width:
|
|
318
|
+
@media (max-width: 780px) {
|
|
319
319
|
flex-direction: column;
|
|
320
320
|
|
|
321
321
|
.Resizer {
|
|
@@ -335,6 +335,7 @@ main {
|
|
|
335
335
|
padding: 16px;
|
|
336
336
|
padding-bottom: 0;
|
|
337
337
|
border-right: 1px solid var(--colorSecondaryActionBorder);
|
|
338
|
+
user-select: none;
|
|
338
339
|
overflow-y: auto;
|
|
339
340
|
box-shadow: var(--boxShadow1);
|
|
340
341
|
}
|
|
@@ -437,7 +438,11 @@ table {
|
|
|
437
438
|
display: flex;
|
|
438
439
|
|
|
439
440
|
> input {
|
|
440
|
-
|
|
441
|
+
/* For click drag target */
|
|
442
|
+
position: absolute;
|
|
443
|
+
width: 22px;
|
|
444
|
+
height: 22px;
|
|
445
|
+
opacity: 0;
|
|
441
446
|
|
|
442
447
|
&:focus {
|
|
443
448
|
outline: 0;
|
package/src/Dashboard.js
CHANGED
|
@@ -98,8 +98,8 @@ const state = {
|
|
|
98
98
|
this.groupByMethod = !this.groupByMethod
|
|
99
99
|
localStorage.setItem('groupByMethod', String(this.groupByMethod))
|
|
100
100
|
},
|
|
101
|
-
|
|
102
|
-
leftSideWidth: undefined
|
|
101
|
+
|
|
102
|
+
leftSideWidth: undefined
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const mockaton = new Commander(window.location.origin)
|
|
@@ -459,25 +459,19 @@ function MockSelector({ broker }) {
|
|
|
459
459
|
|
|
460
460
|
/** @param {{ broker: ClientMockBroker }} props */
|
|
461
461
|
function DelayRouteToggler({ broker }) {
|
|
462
|
-
function
|
|
462
|
+
function commit(checked) {
|
|
463
463
|
const { method, urlMask } = parseFilename(broker.mocks[0])
|
|
464
|
-
mockaton.setRouteIsDelayed(method, urlMask,
|
|
464
|
+
mockaton.setRouteIsDelayed(method, urlMask, checked)
|
|
465
465
|
.then(parseError)
|
|
466
466
|
.catch(onError)
|
|
467
467
|
}
|
|
468
|
-
return (
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
},
|
|
473
|
-
r('input', {
|
|
474
|
-
type: 'checkbox',
|
|
475
|
-
checked: broker.currentMock.delayed,
|
|
476
|
-
onChange
|
|
477
|
-
}),
|
|
478
|
-
TimerIcon()))
|
|
468
|
+
return ClickDragToggler({
|
|
469
|
+
checked: broker.currentMock.delayed,
|
|
470
|
+
commit
|
|
471
|
+
})
|
|
479
472
|
}
|
|
480
473
|
|
|
474
|
+
|
|
481
475
|
/** @param {{ broker: ClientMockBroker }} props */
|
|
482
476
|
function InternalServerErrorToggler({ broker }) {
|
|
483
477
|
function onChange() {
|
|
@@ -558,22 +552,15 @@ function StaticFilesList() {
|
|
|
558
552
|
|
|
559
553
|
/** @param {{ broker: ClientStaticBroker }} props */
|
|
560
554
|
function DelayStaticRouteToggler({ broker }) {
|
|
561
|
-
function
|
|
562
|
-
mockaton.setStaticRouteIsDelayed(broker.route,
|
|
555
|
+
function commit(checked) {
|
|
556
|
+
mockaton.setStaticRouteIsDelayed(broker.route, checked)
|
|
563
557
|
.then(parseError)
|
|
564
558
|
.catch(onError)
|
|
565
559
|
}
|
|
566
|
-
return (
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
},
|
|
571
|
-
r('input', {
|
|
572
|
-
type: 'checkbox',
|
|
573
|
-
checked: broker.delayed,
|
|
574
|
-
onChange
|
|
575
|
-
}),
|
|
576
|
-
TimerIcon()))
|
|
560
|
+
return ClickDragToggler({
|
|
561
|
+
checked: broker.delayed,
|
|
562
|
+
commit
|
|
563
|
+
})
|
|
577
564
|
}
|
|
578
565
|
|
|
579
566
|
/** @param {{ broker: ClientStaticBroker }} props */
|
|
@@ -614,6 +601,40 @@ function ProxyStaticToggler({}) { // TODO
|
|
|
614
601
|
}
|
|
615
602
|
|
|
616
603
|
|
|
604
|
+
function ClickDragToggler({ checked, commit }) {
|
|
605
|
+
function onPointerEnter(event) {
|
|
606
|
+
if (event.buttons === 1)
|
|
607
|
+
onPointerDown.call(this)
|
|
608
|
+
}
|
|
609
|
+
function onPointerDown() {
|
|
610
|
+
this.checked = !this.checked
|
|
611
|
+
commit(this.checked)
|
|
612
|
+
}
|
|
613
|
+
function onClick(event) {
|
|
614
|
+
if (event.pointerType === 'mouse')
|
|
615
|
+
event.preventDefault()
|
|
616
|
+
}
|
|
617
|
+
function onChange() {
|
|
618
|
+
commit(this.checked)
|
|
619
|
+
}
|
|
620
|
+
return (
|
|
621
|
+
r('label', {
|
|
622
|
+
className: CSS.DelayToggler,
|
|
623
|
+
title: Strings.delay
|
|
624
|
+
},
|
|
625
|
+
r('input', {
|
|
626
|
+
type: 'checkbox',
|
|
627
|
+
checked,
|
|
628
|
+
onPointerEnter,
|
|
629
|
+
onPointerDown,
|
|
630
|
+
onClick,
|
|
631
|
+
onChange
|
|
632
|
+
}),
|
|
633
|
+
TimerIcon()))
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
|
|
637
|
+
|
|
617
638
|
function Resizer() {
|
|
618
639
|
return (
|
|
619
640
|
r('div', {
|
|
@@ -627,8 +648,8 @@ Resizer.panelWidth = 0
|
|
|
627
648
|
Resizer.onPointerDown = function (event) {
|
|
628
649
|
Resizer.initialX = event.clientX
|
|
629
650
|
Resizer.panelWidth = leftSideRef.current.clientWidth
|
|
630
|
-
|
|
631
|
-
|
|
651
|
+
addEventListener('pointerup', Resizer.onUp)
|
|
652
|
+
addEventListener('pointermove', Resizer.onMove)
|
|
632
653
|
document.body.style.userSelect = 'none'
|
|
633
654
|
document.body.style.cursor = 'col-resize'
|
|
634
655
|
}
|
|
@@ -641,8 +662,8 @@ Resizer.onMove = function (event) {
|
|
|
641
662
|
})
|
|
642
663
|
}
|
|
643
664
|
Resizer.onUp = function () {
|
|
644
|
-
|
|
645
|
-
|
|
665
|
+
removeEventListener('pointermove', Resizer.onMove)
|
|
666
|
+
removeEventListener('pointerup', Resizer.onUp)
|
|
646
667
|
cancelAnimationFrame(Resizer.raf)
|
|
647
668
|
Resizer.raf = 0
|
|
648
669
|
document.body.style.userSelect = 'auto'
|
package/CHANGELOG.md
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
- 10.0.0 **Breaking Change**: Mockaton constructor is now async. So if you
|
|
4
|
-
use the programmatic launch, instead of the cli, change:
|
|
5
|
-
```js
|
|
6
|
-
Mockaton()
|
|
7
|
-
// to
|
|
8
|
-
await Mockaton()
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
- 9.6.0 dashboard: persist `groupByMethod` preference in localStorage
|
|
14
|
-
- 9.5.0 cli: new log level `verbose`
|
|
15
|
-
- 9.4.0 dashboard: user can resize panels
|
|
16
|
-
- 9.3.0 handle head requests for get mocks
|
|
17
|
-
- 9.2.0 dashboard: syntax highlight more xml files (such as html)
|
|
18
|
-
- 9.1.0 cli: new flag: --no-open
|
|
19
|
-
- 9.0.0 **Breaking Change**: Commander’s GET APIs have been consolidated into `commander.getState()`.
|
|
20
|
-
These were undocumented APIs, so you are likely not affected.
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
- 8.27.0 dashboard: group by method checkbox
|
|
25
|
-
- 8.26.0 ui simplify mock-selector label text
|
|
26
|
-
- 8.25.0 --quiet and logLevel options
|
|
27
|
-
- 8.24.0 show iso date in logs and log static file dispatch
|
|
28
|
-
- 8.23.0 cli
|
|
29
|
-
- 8.22.0 xml syntax highlight
|
|
30
|
-
- 8.21.0 responsive mock list
|
|
31
|
-
- 8.20.0 revert progress bar (no clock spinner)
|
|
32
|
-
- 8.19.0 move puppeteer and pixaton to devDeps
|
|
33
|
-
- 8.18.0 cors. allow by default 'authorization' header
|
|
34
|
-
- 8.17.0 conditionally render proxy toggler
|
|
35
|
-
- 8.16.0 watch static mocks dir
|
|
36
|
-
- 8.15.0 add config.delayJitter
|
|
37
|
-
- 8.14.0 static files controls
|
|
38
|
-
- 8.13.0 highlight dir structure
|
|
39
|
-
- 8.12.0 Adds config.formatCollectedJSON
|
|
40
|
-
- 8.11.0 Allow all the HTTP methods Node.js supports
|
|
41
|
-
- 8.10.0 global delay field
|
|
42
|
-
- 8.9.0 long poll Add or Remove mocks
|
|
43
|
-
- 8.8.0 allow proxying individual routes
|
|
44
|
-
- 8.7.0 dashboard now highlights and previews 500 mocks when checking the 500 toggler
|
|
45
|
-
- 8.6.0 feat: save proxied checkbox
|
|
46
|
-
- 8.5.0 Add demo-app-vite
|
|
47
|
-
- 8.4.0 auto register/unregister mocks
|
|
48
|
-
- 8.3.0 feat `config.collectProxied`
|
|
49
|
-
- 8.2.0 Allow changing proxy fallback server from UI
|
|
50
|
-
- 8.1.0 describe http status code in payload viewer title
|
|
51
|
-
- 8.0.0 **Breaking change**: `config.plugins` are no longer an Object. Now they are an Array and they the
|
|
52
|
-
test is now a regex. So if you use custom plugins, change e.g.:
|
|
53
|
-
```js
|
|
54
|
-
plugins = {
|
|
55
|
-
'.js': jsToJsonPlugin,
|
|
56
|
-
'.ts': jsToJsonPlugin
|
|
57
|
-
}
|
|
58
|
-
// to
|
|
59
|
-
plugins = [
|
|
60
|
-
[/\.(js|ts)$/, jsToJsonPlugin], // Default
|
|
61
|
-
]
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
- 7.8.0 support userland plugins
|
|
67
|
-
- 7.7.0 TypeScript mocks support
|
|
68
|
-
- 7.6.0 render list of static files
|
|
69
|
-
- 7.5.0 allowing previewing mock images
|
|
70
|
-
- 7.4.0 progress bar for payload viewer
|
|
71
|
-
- 7.3.0 Allow CORS Checkbox
|
|
72
|
-
- 7.2.0 add content-type as default header when allowing cors
|
|
73
|
-
- 7.1.0 CORS support
|
|
74
|
-
- 7.0.0 **Breaking change**: Split `PATCH mockaton/edit` into `selectMock` and `setRouteIsDelayed`.
|
|
75
|
-
So instead of:
|
|
76
|
-
```js
|
|
77
|
-
fetch(addr + '/mockaton/edit', {
|
|
78
|
-
method: 'PATCH',
|
|
79
|
-
body: JSON.stringify({
|
|
80
|
-
file: 'api/foo.200.GET.json',
|
|
81
|
-
delayed: true // optional
|
|
82
|
-
})
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
// change it to
|
|
86
|
-
await commander.select('api/foo.200.GET.json')
|
|
87
|
-
await commander.setMockIsDelayed('api/foo.200.GET.json', true)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
- 6.4.0 Default mock could be selected with the comment `(default)`
|
|
93
|
-
- 6.3.0 422 when trying to change a mock that doesn't exist on a route that has mocks
|
|
94
|
-
- 6.4.0 no partial comment search
|
|
95
|
-
- 6.3.0 Allow extending the mime list
|
|
96
|
-
- 6.2.0 Add `config.ignore` regex
|
|
97
|
-
- 6.1.0 remove `config.allowedExt`
|
|
98
|
-
- 6.0.0 **Breaking change**: Remove feature for using .md files for documentating APIs
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
- 5.0.0 **Breaking change**: .md files no longer use status code in the extension
|
|
103
|
-
- 4.0.0 **Breaking change**: rename `config.open` to `config.onReady`
|
|
104
|
-
- 3.0.0 **Breaking change**: `config.skipOpen` boolean to `config.open` function
|
|
105
|
-
|
|
106
|
-
---
|
|
107
|
-
|
|
108
|
-
- 2.3.0 style dashboard
|
|
109
|
-
- 2.2.0 Allow injecting `extraHeaders`
|
|
110
|
-
- 2.1.0 make auto-generate 500's configurable
|
|
111
|
-
- 2.0.0 **Breaking change**: Transforms no longer get a mock
|
|
112
|
-
|
|
113
|
-
---
|
|
114
|
-
|
|
115
|
-
- 1.1.0 Allow writing JSON mocks in JS
|