mockaton 8.20.3 → 8.21.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 CHANGED
@@ -19,11 +19,16 @@ With Mockaton, developers can achieve correctness without sacrificing speed.
19
19
  - Enables testing of complex scenarios that would otherwise be
20
20
  skipped. For example, triggering an error on a third-party API. Or if
21
21
  you are a frontend developer, triggering it on your project’s backend.
22
- - Allows for deterministic, comprehensive, and consistent state.
22
+ - Allows for deterministic, comprehensive, and consistent state, which helps
23
+ spot inadvertent regressions during development, or for setting up screenshot
24
+ tests, e.g., with [pixaton](https://github.com/ericfortis/pixaton).
23
25
 
24
26
  ### Speed
25
27
  - Prevents progress from being blocked by waiting for APIs.
26
28
  - Avoids spinning up and updating hefty backends when developing UIs.
29
+ - Time travel. If you commit the mocks to your repo, it’s straightforward
30
+ to check out long-lived branches and bisect bugs, so you don’t
31
+ have to downgrade backends to old API contracts or databases.
27
32
 
28
33
  <br/>
29
34
 
@@ -44,13 +49,15 @@ For example, for [/api/user/123](#), the filename could be:
44
49
 
45
50
  On the dashboard you can select a mock variant for a particular route, delaying responses,
46
51
  or triggering an autogenerated `500` error, among other features.
52
+
53
+
47
54
  Nonetheless, there’s a programmatic API, which is handy
48
55
  for setting up tests (see **Commander&nbsp;API** section below).
49
56
 
50
57
  <picture>
51
- <source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.vp962x800.light.gold.png">
52
- <source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.vp962x800.dark.gold.png">
53
- <img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.vp962x800.light.gold.png">
58
+ <source media="(prefers-color-scheme: light)" srcset="pixaton-tests/macos/pic-for-readme.vp880x800.light.gold.png">
59
+ <source media="(prefers-color-scheme: dark)" srcset="pixaton-tests/macos/pic-for-readme.vp880x800.dark.gold.png">
60
+ <img alt="Mockaton Dashboard" src="pixaton-tests/macos/pic-for-readme.vp880x800.light.gold.png">
54
61
  </picture>
55
62
 
56
63
 
@@ -92,7 +99,7 @@ get saved following Mockaton’s filename convention.
92
99
  <details>
93
100
  <summary>Details</summary>
94
101
 
95
- This option could be a bit elaborate if your backend uses third-party auth,
102
+ This option could be a bit elaborate if your backend uses third-party authentication,
96
103
  because you’d have to manually inject cookies or `sessionStorage` tokens.
97
104
 
98
105
  On the other hand, proxying to your backend is straightforward if your backend
@@ -118,6 +125,7 @@ Create a `my-mockaton.js` file
118
125
  import { resolve } from 'node:path'
119
126
  import { Mockaton } from 'mockaton'
120
127
 
128
+
121
129
  Mockaton({
122
130
  mocksDir: resolve('my-mocks-dir'), // must exist
123
131
  port: 2345
@@ -175,11 +183,6 @@ permutations for out-of-stock, new-arrival, and discontinued.
175
183
  - Spinners by delaying responses
176
184
  - Setting up UI tests
177
185
 
178
- ### Time travel
179
- If you commit the mocks to your repo, it’s straightforward to
180
- bisect bugs and check out long-lived branches, so you don’t
181
- have to downgrade backends to old API contracts or databases.
182
-
183
186
  ### Simulating complex backend states
184
187
  Sometimes, the ideal flow you need is too difficult to reproduce from the actual backend.
185
188
  For this, you can **Bulk Select** mocks by comments to simulate the complete states
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "8.20.3",
5
+ "version": "8.21.0",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",
package/src/Api.js CHANGED
@@ -60,7 +60,7 @@ function serveDashboard(_, response) {
60
60
  }
61
61
 
62
62
  function serveDashboardAsset(f) {
63
- return (req, response) =>
63
+ return (_, response) =>
64
64
  sendFile(response, join(import.meta.dirname, f))
65
65
  }
66
66
 
package/src/Dashboard.css CHANGED
@@ -125,7 +125,7 @@ header {
125
125
  align-items: flex-end;
126
126
  gap: 16px 10px;
127
127
 
128
- @media (max-width: 890px) {
128
+ @media (max-width: 879px) {
129
129
  max-width: 400px;
130
130
  }
131
131
  }
@@ -235,7 +235,7 @@ header {
235
235
 
236
236
  .Help {
237
237
  min-width: 24px;
238
- align-self: center;
238
+ align-self: end;
239
239
  margin-left: auto;
240
240
  fill: var(--colorSecondaryAction);
241
241
 
@@ -243,7 +243,7 @@ header {
243
243
  fill: var(--colorAccent);
244
244
  }
245
245
 
246
- @media (max-width: 590px) {
246
+ @media (max-width: 520px) {
247
247
  display: none;
248
248
  }
249
249
  }
@@ -256,22 +256,19 @@ main {
256
256
  grid-template-columns: minmax(min-content, max-content) 1fr;
257
257
 
258
258
  @media (max-width: 1160px) {
259
- grid-template-columns: min(620px) 1fr;
259
+ grid-template-columns: min(580px) 1fr;
260
260
  }
261
261
 
262
- @media (max-width: 960px) {
262
+ @media (max-width: 879px) {
263
263
  grid-template-columns: 100%;
264
264
  grid-template-rows: 1fr 1fr;
265
-
266
- .leftSide {
267
- box-shadow: var(--boxShadow1);
268
- }
269
265
  }
270
266
 
271
267
  .leftSide {
272
268
  padding: 16px;
273
269
  padding-bottom: 0;
274
270
  overflow-y: auto;
271
+ box-shadow: var(--boxShadow1);
275
272
  }
276
273
 
277
274
  .rightSide {
@@ -292,6 +289,12 @@ table {
292
289
  tbody {
293
290
  border-bottom: 20px solid transparent;
294
291
  }
292
+
293
+ td:nth-child(3),
294
+ td:nth-child(4),
295
+ td:nth-child(5) {
296
+ max-width: 280px;
297
+ }
295
298
  }
296
299
 
297
300
  .empty {
@@ -323,7 +326,7 @@ table {
323
326
  .MockSelector {
324
327
  width: 100%;
325
328
  height: 26px;
326
- padding-right: 8px;
329
+ padding-right: 16px;
327
330
  padding-left: 8px;
328
331
  text-overflow: ellipsis;
329
332
  font-size: 12px;
@@ -343,7 +346,7 @@ table {
343
346
  background: transparent;
344
347
  cursor: default;
345
348
  color: var(--colorDisabledMockSelector);
346
- opacity: 1;
349
+ opacity: 0.8;
347
350
  }
348
351
  }
349
352
 
package/src/Dashboard.js CHANGED
@@ -597,8 +597,8 @@ async function previewMock(method, urlMask, href) {
597
597
  previewMock.controller?.abort()
598
598
  previewMock.controller = new AbortController
599
599
 
600
- renderProgressBar()
601
600
  payloadViewerTitleRef.current.replaceChildren(r('span', null, Strings.fetching))
601
+ payloadViewerRef.current.replaceChildren(PayloadViewerProgressBar())
602
602
 
603
603
  try {
604
604
  const response = await fetch(href, {
@@ -607,10 +607,9 @@ async function previewMock(method, urlMask, href) {
607
607
  })
608
608
  await updatePayloadViewer(method, urlMask, response)
609
609
  }
610
- catch {}
611
-
612
- function renderProgressBar() {
613
- payloadViewerRef.current.replaceChildren(PayloadViewerProgressBar())
610
+ catch (err) {
611
+ onError(err)
612
+ payloadViewerRef.current.replaceChildren()
614
613
  }
615
614
  }
616
615
 
@@ -755,7 +754,9 @@ async function poll() {
755
754
  /** # Utils */
756
755
 
757
756
  function className(...args) {
758
- return { className: args.filter(Boolean).join(' ') }
757
+ return {
758
+ className: args.filter(Boolean).join(' ')
759
+ }
759
760
  }
760
761
 
761
762
 
@@ -3,7 +3,7 @@ import { listFilesRecursively } from './utils/fs.js'
3
3
  import { config, isFileAllowed } from './config.js'
4
4
 
5
5
 
6
- export class StaticBroker {
6
+ class StaticBroker {
7
7
  constructor(route) {
8
8
  this.route = route
9
9
  this.delayed = false