@brillout/test-e2e 0.5.28 → 0.5.29
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/dist/testScreenshotFixture.js +26 -7
- package/package.json +15 -3
|
@@ -17,14 +17,33 @@ async function testScreenshotFixture({ screenshotFixturePath, doNotTestLocally,
|
|
|
17
17
|
const pngPaths = getPngPaths();
|
|
18
18
|
const pngFixturPath = screenshotFixturePath || pngPaths.pngFixturPath;
|
|
19
19
|
if (doNotTestLocally && !(0, utils_1.isCI)()) {
|
|
20
|
-
console.log(`\n${picocolors_1.default.blue('INFO')} screenshot
|
|
20
|
+
console.log(`\n${picocolors_1.default.blue('INFO')} test screenshot fixture ${pngFixturPath} ${picocolors_1.default.bold('skipped')}. (Because ${picocolors_1.default.cyan('doNotTestLocally: true')} and test is being run locally, i.e. not in a CI environment.)`);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
const fixtureMissing = !fs_1.default.existsSync(pngFixturPath);
|
|
24
|
+
if (fixtureMissing) {
|
|
24
25
|
const pngActual = await takeScreenshot();
|
|
25
26
|
const fileContent = pngjs_1.PNG.sync.write(pngActual);
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const { pngExpectPath } = pngPaths;
|
|
28
|
+
const filPath = (0, utils_1.isCI)() ? pngExpectPath : pngFixturPath;
|
|
29
|
+
fs_1.default.writeFileSync(filPath, fileContent);
|
|
30
|
+
console.log('Expect image written at', pngExpectPath);
|
|
31
|
+
const errMsgs = [
|
|
32
|
+
//
|
|
33
|
+
'Screenshot fixture missing. Screenshot fixture created at:',
|
|
34
|
+
` ${filPath}`,
|
|
35
|
+
];
|
|
36
|
+
if (!(0, utils_1.isCI)()) {
|
|
37
|
+
errMsgs.push('You can now re-run the test and the screenshot fixture test will pass.');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
errMsgs.push([
|
|
41
|
+
'The screnshot fixture was uploaded as GitHub Workflow Artifact.',
|
|
42
|
+
`(See ${picocolors_1.default.bold('Summary')} > ${picocolors_1.default.bold('Artifacts')}, and make sure to use the ${picocolors_1.default.bold('actions/upload-artifact@v3')} action.)`,
|
|
43
|
+
`Download the fixture, check it into the repository (so that it lives at ${pngFixturPath}), and try again: the test should now pass.`,
|
|
44
|
+
].join(' '));
|
|
45
|
+
}
|
|
46
|
+
throw new Error(errMsgs.join('\n'));
|
|
28
47
|
}
|
|
29
48
|
const pngExpect = pngjs_1.PNG.sync.read(fs_1.default.readFileSync(pngFixturPath));
|
|
30
49
|
const pngActual = await takeScreenshot();
|
|
@@ -39,16 +58,16 @@ async function testScreenshotFixture({ screenshotFixturePath, doNotTestLocally,
|
|
|
39
58
|
catch (err) {
|
|
40
59
|
const { pngExpectPath, pngActualPath, pngDifferPath } = pngPaths;
|
|
41
60
|
{
|
|
42
|
-
console.log('Actual image written at', pngActualPath);
|
|
43
61
|
fs_1.default.writeFileSync(pngActualPath, pngjs_1.PNG.sync.write(pngActual));
|
|
62
|
+
console.log('Actual image written at', pngActualPath);
|
|
44
63
|
}
|
|
45
64
|
{
|
|
46
|
-
console.log('Expect image written at', pngExpectPath);
|
|
47
65
|
fs_1.default.writeFileSync(pngExpectPath, pngjs_1.PNG.sync.write(pngExpect));
|
|
66
|
+
console.log('Expect image written at', pngExpectPath);
|
|
48
67
|
}
|
|
49
68
|
{
|
|
50
|
-
console.log('Differ image written at', pngDifferPath);
|
|
51
69
|
fs_1.default.writeFileSync(pngDifferPath, pngjs_1.PNG.sync.write(pngDiffer));
|
|
70
|
+
console.log('Differ image written at', pngDifferPath);
|
|
52
71
|
}
|
|
53
72
|
throw err;
|
|
54
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/test-e2e",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.29",
|
|
4
4
|
"bin": "./bin.js",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,15 +10,24 @@
|
|
|
10
10
|
"build": "rm -rf dist/ && tsc",
|
|
11
11
|
"// === Release ===": "",
|
|
12
12
|
"prepublishOnly": "pnpm run build",
|
|
13
|
-
"release": "npm version patch && npm publish && git push && git push --tags"
|
|
13
|
+
"release": "npm version patch && npm publish && git push && git push --tags",
|
|
14
|
+
"========= Clean": "",
|
|
15
|
+
"reset": "git clean -Xdf && pnpm install && pnpm run build",
|
|
16
|
+
"========= Formatting": "",
|
|
17
|
+
"format": "pnpm run format:biome",
|
|
18
|
+
"format:prettier": "git ls-files | egrep '\\.(json|js|jsx|css|ts|tsx|vue|mjs|cjs)$' | grep --invert-match package.json | xargs pnpm exec prettier --write",
|
|
19
|
+
"format:biome": "biome format --write .",
|
|
20
|
+
"format:check": "biome format . || echo Fix formatting by running: $ pnpm run format",
|
|
21
|
+
"========= Only allow pnpm; forbid yarn & npm": "",
|
|
22
|
+
"preinstall": "npx only-allow pnpm"
|
|
14
23
|
},
|
|
15
24
|
"dependencies": {
|
|
16
25
|
"@brillout/part-regex": "^0.1.3",
|
|
26
|
+
"@brillout/picocolors": "^1.0.9",
|
|
17
27
|
"chai": "^4.3.6",
|
|
18
28
|
"esbuild": "^0.16.5",
|
|
19
29
|
"fast-glob": "^3.2.12",
|
|
20
30
|
"node-fetch": "^2.6.1",
|
|
21
|
-
"@brillout/picocolors": "^1.0.9",
|
|
22
31
|
"pixelmatch": "^5.3.0",
|
|
23
32
|
"playwright-chromium": "^1.22.2",
|
|
24
33
|
"pngjs": "^6.0.0",
|
|
@@ -26,14 +35,17 @@
|
|
|
26
35
|
"strip-ansi": "^6.0.1"
|
|
27
36
|
},
|
|
28
37
|
"devDependencies": {
|
|
38
|
+
"@biomejs/biome": "^1.5.3",
|
|
29
39
|
"@types/chai": "^4.3.3",
|
|
30
40
|
"@types/node": "^15.6.1",
|
|
31
41
|
"@types/node-fetch": "^2.5.12",
|
|
32
42
|
"@types/pixelmatch": "^5.2.4",
|
|
33
43
|
"@types/pngjs": "^6.0.1",
|
|
34
44
|
"@types/source-map-support": "^0.5.6",
|
|
45
|
+
"prettier": "^3.2.5",
|
|
35
46
|
"typescript": "^4.8.3"
|
|
36
47
|
},
|
|
48
|
+
"packageManager": "pnpm@8.15.1",
|
|
37
49
|
"repository": "github:brillout/test-e2e",
|
|
38
50
|
"files": [
|
|
39
51
|
"dist/"
|