mockaton 8.2.1 → 8.2.3
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 +5 -9
- package/package.json +1 -1
- package/.editorconfig +0 -11
- package/README-dashboard-dark.png +0 -0
- package/README-dashboard-light.png +0 -0
- package/sample-mocks/api/user/avatar.GET.200.png +0 -0
- package/sample-mocks/api/user/edit-name.PATCH.200.json +0 -3
- package/sample-mocks/api/user/edit-name.PATCH.422.json +0 -3
- package/sample-mocks/api/user/friends.GET.200.json +0 -3
- package/sample-mocks/api/user/friends.GET.204.json +0 -4
- package/sample-mocks/api/user/friends.GET.500.txt +0 -7
- package/sample-mocks/api/user/likes.GET.200.js +0 -9
- package/sample-mocks/api/user/links.GET.200.js +0 -9
- package/sample-mocks/api/user/logout.POST.200.json +0 -1
- package/sample-mocks/api/user/typescript-scores-full.GET.200.ts +0 -9
- package/sample-mocks/api/user/typescript-scores.GET.200.ts +0 -6
- package/sample-mocks/api/user/videos(all variants).GET.200.json +0 -13
- package/sample-mocks/api/user/videos(default).GET.200.json +0 -13
- package/sample-mocks/api/user/videos(verified)(another comment).GET.200.json +0 -13
- package/sample-mocks/api/user/yaml-fruits.GET.200.yml +0 -5
- package/sample-mocks/api/user.GET.200.json +0 -4
- package/sample-mocks/api/video/[id].GET.200.json +0 -4
- package/sample-mocks/api/video/stat/[stat-id]/[video-id].GET.200.json +0 -3
- package/sample-mocks/api/video/stat/[stat-id]/all-videos?limit=[limit].GET.200.json +0 -4
- package/sample-static/another-entry/index.html +0 -35
- package/sample-static/assets/video.mp4 +0 -0
- package/sample-static/index.html +0 -37
- package/ui-tests/_setup.js +0 -37
- package/ui-tests/bulk-select.test.js +0 -10
- package/ui-tests/bulk-select.vp1024x800.dark.gold.png +0 -0
- package/ui-tests/bulk-select.vp1024x800.light.gold.png +0 -0
- package/ui-tests/initial-dashboard-state.test.js +0 -4
- package/ui-tests/initial-dashboard-state.vp1024x800.dark.gold.png +0 -0
- package/ui-tests/initial-dashboard-state.vp1024x800.light.gold.png +0 -0
- package/ui-tests/payload-viewer-formats-json.test.js +0 -9
- package/ui-tests/payload-viewer-formats-json.vp1024x800.dark.gold.png +0 -0
- package/ui-tests/payload-viewer-formats-json.vp1024x800.light.gold.png +0 -0
- package/ui-tests/payload-viewer-renders-images.test.js +0 -9
- package/ui-tests/payload-viewer-renders-images.vp1024x800.dark.gold.png +0 -0
- package/ui-tests/payload-viewer-renders-images.vp1024x800.light.gold.png +0 -0
- package/ui-tests/select-mock-variant.test.js +0 -10
- package/ui-tests/select-mock-variant.vp1024x800.dark.gold.png +0 -0
- package/ui-tests/select-mock-variant.vp1024x800.light.gold.png +0 -0
package/README.md
CHANGED
|
@@ -127,24 +127,20 @@ database, or pull data from a backend.
|
|
|
127
127
|
Don’t call `response.end()`, just return a `string | Buffer | Uint8Array`.
|
|
128
128
|
|
|
129
129
|
```js
|
|
130
|
-
|
|
131
|
-
export default function optionalName(request, response) {
|
|
130
|
+
export default function requestCounter(request, response) {
|
|
132
131
|
globalThis.myDatabase ??= { count: 0 }
|
|
133
132
|
globalThis.myDatabase.count++
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
response.setHeader('Content-Type', 'application/json')
|
|
138
|
-
|
|
139
|
-
return JSON.stringify({ a: 1 })
|
|
133
|
+
return JSON.stringify({
|
|
134
|
+
count: globalThis.myDatabase.count
|
|
135
|
+
})
|
|
140
136
|
}
|
|
141
137
|
```
|
|
142
138
|
|
|
143
139
|
If you need to serve a static `.js` file, put it in your
|
|
144
140
|
`Config.staticDir` without the mock filename convention.
|
|
145
141
|
|
|
146
|
-
This example will echo back the request body concatenated with another fixture.
|
|
147
142
|
```js
|
|
143
|
+
// This example will echo the request body concatenated with another fixture.
|
|
148
144
|
// api/color.POST.201.js
|
|
149
145
|
|
|
150
146
|
import colors from './colors.json' with { type: 'json' }
|
package/package.json
CHANGED
package/.editorconfig
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
This is a plain text response for (/api/friends).
|
|
2
|
-
|
|
3
|
-
In this case, it’s for mocking up a 500 - Internal Server Error.
|
|
4
|
-
|
|
5
|
-
This file could have been empty, or some JSON if it had a `.json` extension.
|
|
6
|
-
|
|
7
|
-
By the way, on initialization an 500 is auto-generated for routes that don’t have a 500.
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// You can write JSON responses in JavaScript as a function.
|
|
2
|
-
// Must return a String and they should NOT call `response.end()`
|
|
3
|
-
|
|
4
|
-
export default function (req, response) {
|
|
5
|
-
return JSON.stringify([
|
|
6
|
-
'http://example.com/foo',
|
|
7
|
-
'http://example.com/bar'
|
|
8
|
-
], null, 2)
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
""
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_": "This file has a comment: `(default)`. Which makes the file with comment: (all variants) not to win",
|
|
3
|
-
"videos": [
|
|
4
|
-
{
|
|
5
|
-
"url": "https://example.com/1",
|
|
6
|
-
"verified": false
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"url": "https://example.com/2",
|
|
10
|
-
"verified": false
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"_": "This file has two comments: `(entirely verified)` and `(another comment)`. i.e. the route is /api/user/videos",
|
|
3
|
-
"videos": [
|
|
4
|
-
{
|
|
5
|
-
"url": "https://example.com/1",
|
|
6
|
-
"verified": true
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"url": "https://example.com/2",
|
|
10
|
-
"verified": true
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta content="width=device-width" name="viewport">
|
|
6
|
-
<link rel="icon" href="data:">
|
|
7
|
-
<title>Another Entry Point</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<h1>Another Entry Point</h1>
|
|
11
|
-
|
|
12
|
-
<h2>/api/user</h2>
|
|
13
|
-
<pre></pre>
|
|
14
|
-
<script>
|
|
15
|
-
(async () => {
|
|
16
|
-
let output = ''
|
|
17
|
-
try {
|
|
18
|
-
const response = await fetch('/api/user')
|
|
19
|
-
if (response.ok) {
|
|
20
|
-
const json = await response.json()
|
|
21
|
-
output = JSON.stringify(json, null, 2)
|
|
22
|
-
}
|
|
23
|
-
else
|
|
24
|
-
throw response.status
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
output = 'Error: ' + error
|
|
28
|
-
}
|
|
29
|
-
finally {
|
|
30
|
-
document.querySelector('pre').innerText = output
|
|
31
|
-
}
|
|
32
|
-
})()
|
|
33
|
-
</script>
|
|
34
|
-
</body>
|
|
35
|
-
</html>
|
|
Binary file
|
package/sample-static/index.html
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8">
|
|
5
|
-
<meta content="width=device-width" name="viewport">
|
|
6
|
-
<link rel="icon" href="data:">
|
|
7
|
-
<title>Title</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<h1>Welcome!</h1>
|
|
11
|
-
<video src="assets/video.mp4" width="720" controls></video>
|
|
12
|
-
|
|
13
|
-
<h2>/api/user</h2>
|
|
14
|
-
<pre></pre>
|
|
15
|
-
|
|
16
|
-
<script>
|
|
17
|
-
(async () => {
|
|
18
|
-
let output = ''
|
|
19
|
-
try {
|
|
20
|
-
const response = await fetch('/api/user')
|
|
21
|
-
if (response.ok) {
|
|
22
|
-
const json = await response.json()
|
|
23
|
-
output = JSON.stringify(json, null, 2)
|
|
24
|
-
}
|
|
25
|
-
else
|
|
26
|
-
throw response.status
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
output = 'Error: ' + error
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
document.querySelector('pre').innerText = output
|
|
33
|
-
}
|
|
34
|
-
})()
|
|
35
|
-
</script>
|
|
36
|
-
</body>
|
|
37
|
-
</html>
|
package/ui-tests/_setup.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { after } from 'node:test'
|
|
2
|
-
import { launch } from 'puppeteer'
|
|
3
|
-
import {
|
|
4
|
-
removeDiffsAndCandidates,
|
|
5
|
-
testPixels as _testPixels,
|
|
6
|
-
diffServer
|
|
7
|
-
} from 'pixaton'
|
|
8
|
-
import { Commander } from '../index.js'
|
|
9
|
-
|
|
10
|
-
// Before running these tests you need to spin up the demo:
|
|
11
|
-
// npm run demo
|
|
12
|
-
|
|
13
|
-
const MOCKATON_ADDR = 'http://localhost:2345'
|
|
14
|
-
const mockaton = new Commander(MOCKATON_ADDR)
|
|
15
|
-
|
|
16
|
-
const testsDir = import.meta.dirname
|
|
17
|
-
|
|
18
|
-
removeDiffsAndCandidates(testsDir)
|
|
19
|
-
const browser = await launch({ headless: true })
|
|
20
|
-
const page = await browser.newPage()
|
|
21
|
-
|
|
22
|
-
after(() => {
|
|
23
|
-
browser?.close()
|
|
24
|
-
diffServer(testsDir)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
export function testPixels(testFileName, options = {}) {
|
|
28
|
-
options.beforeSuite = async () => await mockaton.reset()
|
|
29
|
-
options.viewports ??= [{
|
|
30
|
-
width: 1024,
|
|
31
|
-
height: 800,
|
|
32
|
-
deviceScaleFactor: 1.5 // for better screenshots
|
|
33
|
-
}]
|
|
34
|
-
options.colorSchemes ??= ['light', 'dark']
|
|
35
|
-
options.screenshotOptions ??= {}
|
|
36
|
-
_testPixels(page, testFileName, MOCKATON_ADDR + '/mockaton', 'body', options)
|
|
37
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|