mockaton 8.2.8 → 8.2.9

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.
Files changed (2) hide show
  1. package/README.md +39 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -62,22 +62,47 @@ Experiment with the Dashboard:
62
62
  - Pick a mock variant from the Mock dropdown (we’ll discuss them later)
63
63
  - Toggle the 🕓 Clock button, which _Delays_ responses (e.g. for testing spinners)
64
64
  - Toggle the _500_ button, which sends and _Internal Server Error_ on that endpoint
65
+ - Click `index.html` in the "Static" section
66
+ - see what for in the "Deterministic Standalone Demo Server" use case below
65
67
 
66
68
  Finally, edit a mock file in your IDE. You don’t need to restart Mockaton for that.
67
69
  The _Reset_ button is for registering newly added, removed, or renamed mocks.
68
70
 
69
71
 
70
72
  ## Use Cases
71
- - Test empty responses
72
- - Test spinners by delaying responses
73
- - Test errors such as _Bad Request_ and _Internal Server Error_
74
- - Trigger polled resources such as notifications and alerts
75
- - Prototype before the backend API is developed
76
- - Setup tests
77
- - As API documentation
78
- - If you commit the mocks in the repo, when bisecting a bug, you don’t
79
- have to sync the frontend with many backend repos
80
- - Similarly, it allows for checking out long-lived branches that have old API contracts
73
+ ### Testing
74
+ - Empty responses
75
+ - Spinners by delaying responses
76
+ - Errors such as _Bad Request_ and _Internal Server Error_
77
+ - Setting up UI tests
78
+ - Polled resources (trigger different states)
79
+ - alerts
80
+ - notifications
81
+ - slow to build assets
82
+
83
+ ### Prototype Ahead of Backend
84
+ Sometimes, frontend progress is needlessly blocked waiting for some
85
+ backend API. Similarly, it’s often delayed due to missing data or inconvenient
86
+ contracts. Therefore, many meetings can be saved by prototyping frontend
87
+ features with mocks, and then showing those contracts to the backend team.
88
+
89
+ They won’t like it at first.
90
+
91
+ ### Time Travel
92
+ If you commit the mocks in the repo, when bisecting a bug, you don’t
93
+ have to sync the frontend with many backend repos. Similarly, it
94
+ allows for checking out long-lived branches that have old API contracts.
95
+
96
+ ### Deterministic Standalone Demo Server
97
+ Perhaps you need to demo your app, but the ideal flow is too complex to
98
+ simulate from the actual backend. In this case, compile your frontend app and
99
+ put its built assets in `Config.staticDir`. Then, from the Mockaton dashboard
100
+ you can "Bulk Select" mocks to simulate the complete states you want to demo.
101
+
102
+ For bulk-selecting, you just need to add a comment to the mock
103
+ filename. For example, `(demo-part1)`, `(demo-part2)`. See the
104
+ "Comments" section under the "Filename Convention" for details.
105
+
81
106
 
82
107
  ## Motivation
83
108
  - Avoids spinning up and maintaining hefty backends when developing UIs.
@@ -134,19 +159,19 @@ database, or pull data from a backend.
134
159
  <details>
135
160
  <summary><b>See More Examples</b></summary>
136
161
 
137
- For example, imagine you have an initial list of
138
- colors, and you want to concatenate newly added colors.
162
+ Imagine you have an initial list of colors, and
163
+ you want to concatenate newly added colors.
139
164
 
140
165
  `api/colors.POST.201.js`
141
166
  ```js
142
- import { parseJSON } from 'mockaton' // body-parser alike
167
+ import { parseJSON } from 'mockaton'
143
168
 
144
169
  export default async function insertColor(request, response) {
145
170
  const color = await parseJSON(request)
146
171
  globalThis.newColorsDatabase ??= []
147
172
  globalThis.newColorsDatabase.push(color)
148
173
 
149
- // These two lines are not needed but you can change them
174
+ // These two lines are not needed but you can change their values
150
175
  // response.statusCode = 201 // default derived from filename
151
176
  // response.setHeader('Content-Type', 'application/json') // unconditional default
152
177
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "A deterministic server-side for developing and testing frontend clients",
4
4
  "type": "module",
5
- "version": "8.2.8",
5
+ "version": "8.2.9",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "license": "MIT",