lighthouse-reporting 1.6.8 → 1.6.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.
- package/dist/constants-CFLum58k.js +6 -0
- package/dist/constants-WB1XbOZm.cjs +23 -0
- package/dist/hooks.cjs +21 -18
- package/dist/hooks.js +13 -16
- package/dist/index.cjs +13 -14
- package/dist/index.js +1 -11
- package/dist/lighthouse-reporting.umd.cjs +280 -256
- package/dist/lighthouseReports.cjs +82 -84
- package/dist/lighthouseReports.js +78 -88
- package/dist/playwrightLighthouseTest.cjs +20 -28
- package/dist/playwrightLighthouseTest.js +14 -27
- package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
- package/dist/storybookPlaywright.cjs +27 -30
- package/dist/storybookPlaywright.js +24 -30
- package/package.json +13 -12
- package/dist/constants-ClvZzVIQ.cjs +0 -7
- package/dist/constants-CvRW9vHz.js +0 -8
- /package/dist/{lighthouse.html → src/lighthouse.html} +0 -0
|
@@ -1,93 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
|
|
3
|
+
let path = require("path");
|
|
4
|
+
path = require_rolldown_runtime.__toESM(path, 1);
|
|
5
|
+
let fs_extra = require("fs-extra");
|
|
6
|
+
fs_extra = require_rolldown_runtime.__toESM(fs_extra, 1);
|
|
7
|
+
//#region src/lighthouseReports.ts
|
|
8
|
+
var writeCsvResult = async (reportDir, name, scores, thresholds = {}, swimlanes = []) => {
|
|
9
|
+
let csvData = Object.keys(scores).join(",");
|
|
10
|
+
if (swimlanes.length > 0) csvData += "," + swimlanes.map((swimlane) => `${swimlane}_threshold`);
|
|
11
|
+
csvData += "\n";
|
|
12
|
+
csvData += Object.values(scores).join(",");
|
|
13
|
+
if (swimlanes.length > 0 && Object.keys(thresholds).length > 0) csvData += "," + swimlanes.map((swimlane) => thresholds[swimlane]);
|
|
14
|
+
await fs_extra.default.writeFile(path.default.join(reportDir, `${name}.csv`), csvData);
|
|
16
15
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
var writeHtmlListEntry = async (htmlFilePath, name, scores, thresholds, error, addReportLink) => {
|
|
17
|
+
const htmlFileData = (await fs_extra.default.readFile(htmlFilePath)).toString("utf-8").split("\n");
|
|
18
|
+
const insertIdx = htmlFileData.findIndex((v) => v.includes("// lighthouse-page-results"));
|
|
19
|
+
if (insertIdx < 0) throw new Error("Failed to write results to index.html");
|
|
20
|
+
htmlFileData.splice(insertIdx + 1, 0, JSON.stringify({
|
|
21
|
+
href: `${name}.html`,
|
|
22
|
+
name,
|
|
23
|
+
scores,
|
|
24
|
+
thresholds,
|
|
25
|
+
error,
|
|
26
|
+
addReportLink
|
|
27
|
+
}) + ",");
|
|
28
|
+
await fs_extra.default.writeFile(htmlFilePath, htmlFileData.join("\n"));
|
|
25
29
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
/**
|
|
31
|
+
* workaround conflicts when multiple threads write the same file
|
|
32
|
+
*/
|
|
33
|
+
var writeHtmlListEntryWithRetry = async (htmlFilePath, name, scores, thresholds, comparisonError, addReportLink = true) => {
|
|
34
|
+
let attempts = 10;
|
|
35
|
+
let error;
|
|
36
|
+
while (attempts > 0) {
|
|
37
|
+
attempts--;
|
|
38
|
+
try {
|
|
39
|
+
await writeHtmlListEntry(htmlFilePath, name, scores, thresholds, comparisonError, addReportLink);
|
|
40
|
+
return;
|
|
41
|
+
} catch (e) {
|
|
42
|
+
error = e;
|
|
43
|
+
}
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
45
|
+
}
|
|
46
|
+
throw error;
|
|
40
47
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
title: result.lhr.audits[v.id].title,
|
|
60
|
-
nodes: v.nodes.length
|
|
61
|
-
};
|
|
62
|
-
}) : [];
|
|
63
|
-
if (accessibilityViolations.length > 0) {
|
|
64
|
-
json.accessibility.issues = accessibilityViolations;
|
|
65
|
-
}
|
|
66
|
-
await fse.writeFile(path.join(lhScoresDir, `${name}.json`), JSON.stringify(json, null, 2));
|
|
48
|
+
var getScores = (result) => Object.entries(result.lhr.categories).reduce((prev, [key, c]) => {
|
|
49
|
+
const score = typeof c.score === "number" ? c.score : 0;
|
|
50
|
+
prev[key] = Math.floor(score * 100);
|
|
51
|
+
return prev;
|
|
52
|
+
}, {});
|
|
53
|
+
var writeScoresToJson = async (lhScoresDir, name, scores, result) => {
|
|
54
|
+
const json = Object.entries(scores).reduce((prev, [k, score]) => {
|
|
55
|
+
prev[k] = { score };
|
|
56
|
+
return prev;
|
|
57
|
+
}, {});
|
|
58
|
+
const accessibilityViolations = result.artifacts.Accessibility ? result.artifacts.Accessibility.violations.map((v) => {
|
|
59
|
+
return {
|
|
60
|
+
title: result.lhr.audits[v.id].title,
|
|
61
|
+
nodes: v.nodes.length
|
|
62
|
+
};
|
|
63
|
+
}) : [];
|
|
64
|
+
if (accessibilityViolations.length > 0) json.accessibility.issues = accessibilityViolations;
|
|
65
|
+
await fs_extra.default.writeFile(path.default.join(lhScoresDir, `${name}.json`), JSON.stringify(json, null, 2));
|
|
67
66
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
});
|
|
89
|
-
await writeCsvResult(reportDir, "_AVERAGE_", scores);
|
|
67
|
+
/**
|
|
68
|
+
* Generate average csv file. Make sure to use `writeScoresToJson` in your test!
|
|
69
|
+
* @param lhScoresDir path to folder with lighthouse json files. See `writeScoresToJson`.
|
|
70
|
+
* @param reportDir folder where `_AVERAGE_.json` will be generated
|
|
71
|
+
*/
|
|
72
|
+
var buildAverageCsv = async (lhScoresDir, reportDir) => {
|
|
73
|
+
const jsonFiles = (await fs_extra.default.readdir(lhScoresDir)).filter((f) => f.endsWith(".json"));
|
|
74
|
+
if (jsonFiles.length === 0) return;
|
|
75
|
+
const scores = {};
|
|
76
|
+
for (const fileName of jsonFiles) {
|
|
77
|
+
const score = await fs_extra.default.readJson(path.default.join(lhScoresDir, fileName));
|
|
78
|
+
Object.entries(score).forEach(([k, v]) => {
|
|
79
|
+
if (!scores[k]) scores[k] = 0;
|
|
80
|
+
scores[k] += v.score;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
Object.entries(scores).forEach(([k, v]) => {
|
|
84
|
+
scores[k] = v / jsonFiles.length;
|
|
85
|
+
});
|
|
86
|
+
await writeCsvResult(reportDir, "_AVERAGE_", scores);
|
|
90
87
|
};
|
|
88
|
+
//#endregion
|
|
91
89
|
exports.buildAverageCsv = buildAverageCsv;
|
|
92
90
|
exports.getScores = getScores;
|
|
93
91
|
exports.writeCsvResult = writeCsvResult;
|
|
@@ -1,95 +1,85 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fse from "fs-extra";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
csvData += "," + swimlanes.map((swimlane) => thresholds[swimlane]);
|
|
12
|
-
}
|
|
13
|
-
await fse.writeFile(path.join(reportDir, `${name}.csv`), csvData);
|
|
3
|
+
//#region src/lighthouseReports.ts
|
|
4
|
+
var writeCsvResult = async (reportDir, name, scores, thresholds = {}, swimlanes = []) => {
|
|
5
|
+
let csvData = Object.keys(scores).join(",");
|
|
6
|
+
if (swimlanes.length > 0) csvData += "," + swimlanes.map((swimlane) => `${swimlane}_threshold`);
|
|
7
|
+
csvData += "\n";
|
|
8
|
+
csvData += Object.values(scores).join(",");
|
|
9
|
+
if (swimlanes.length > 0 && Object.keys(thresholds).length > 0) csvData += "," + swimlanes.map((swimlane) => thresholds[swimlane]);
|
|
10
|
+
await fse.writeFile(path.join(reportDir, `${name}.csv`), csvData);
|
|
14
11
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
var writeHtmlListEntry = async (htmlFilePath, name, scores, thresholds, error, addReportLink) => {
|
|
13
|
+
const htmlFileData = (await fse.readFile(htmlFilePath)).toString("utf-8").split("\n");
|
|
14
|
+
const insertIdx = htmlFileData.findIndex((v) => v.includes("// lighthouse-page-results"));
|
|
15
|
+
if (insertIdx < 0) throw new Error("Failed to write results to index.html");
|
|
16
|
+
htmlFileData.splice(insertIdx + 1, 0, JSON.stringify({
|
|
17
|
+
href: `${name}.html`,
|
|
18
|
+
name,
|
|
19
|
+
scores,
|
|
20
|
+
thresholds,
|
|
21
|
+
error,
|
|
22
|
+
addReportLink
|
|
23
|
+
}) + ",");
|
|
24
|
+
await fse.writeFile(htmlFilePath, htmlFileData.join("\n"));
|
|
23
25
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
/**
|
|
27
|
+
* workaround conflicts when multiple threads write the same file
|
|
28
|
+
*/
|
|
29
|
+
var writeHtmlListEntryWithRetry = async (htmlFilePath, name, scores, thresholds, comparisonError, addReportLink = true) => {
|
|
30
|
+
let attempts = 10;
|
|
31
|
+
let error;
|
|
32
|
+
while (attempts > 0) {
|
|
33
|
+
attempts--;
|
|
34
|
+
try {
|
|
35
|
+
await writeHtmlListEntry(htmlFilePath, name, scores, thresholds, comparisonError, addReportLink);
|
|
36
|
+
return;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
error = e;
|
|
39
|
+
}
|
|
40
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
38
43
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
title: result.lhr.audits[v.id].title,
|
|
58
|
-
nodes: v.nodes.length
|
|
59
|
-
};
|
|
60
|
-
}) : [];
|
|
61
|
-
if (accessibilityViolations.length > 0) {
|
|
62
|
-
json.accessibility.issues = accessibilityViolations;
|
|
63
|
-
}
|
|
64
|
-
await fse.writeFile(path.join(lhScoresDir, `${name}.json`), JSON.stringify(json, null, 2));
|
|
44
|
+
var getScores = (result) => Object.entries(result.lhr.categories).reduce((prev, [key, c]) => {
|
|
45
|
+
const score = typeof c.score === "number" ? c.score : 0;
|
|
46
|
+
prev[key] = Math.floor(score * 100);
|
|
47
|
+
return prev;
|
|
48
|
+
}, {});
|
|
49
|
+
var writeScoresToJson = async (lhScoresDir, name, scores, result) => {
|
|
50
|
+
const json = Object.entries(scores).reduce((prev, [k, score]) => {
|
|
51
|
+
prev[k] = { score };
|
|
52
|
+
return prev;
|
|
53
|
+
}, {});
|
|
54
|
+
const accessibilityViolations = result.artifacts.Accessibility ? result.artifacts.Accessibility.violations.map((v) => {
|
|
55
|
+
return {
|
|
56
|
+
title: result.lhr.audits[v.id].title,
|
|
57
|
+
nodes: v.nodes.length
|
|
58
|
+
};
|
|
59
|
+
}) : [];
|
|
60
|
+
if (accessibilityViolations.length > 0) json.accessibility.issues = accessibilityViolations;
|
|
61
|
+
await fse.writeFile(path.join(lhScoresDir, `${name}.json`), JSON.stringify(json, null, 2));
|
|
65
62
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
await writeCsvResult(reportDir, "_AVERAGE_", scores);
|
|
88
|
-
};
|
|
89
|
-
export {
|
|
90
|
-
buildAverageCsv,
|
|
91
|
-
getScores,
|
|
92
|
-
writeCsvResult,
|
|
93
|
-
writeHtmlListEntryWithRetry,
|
|
94
|
-
writeScoresToJson
|
|
63
|
+
/**
|
|
64
|
+
* Generate average csv file. Make sure to use `writeScoresToJson` in your test!
|
|
65
|
+
* @param lhScoresDir path to folder with lighthouse json files. See `writeScoresToJson`.
|
|
66
|
+
* @param reportDir folder where `_AVERAGE_.json` will be generated
|
|
67
|
+
*/
|
|
68
|
+
var buildAverageCsv = async (lhScoresDir, reportDir) => {
|
|
69
|
+
const jsonFiles = (await fse.readdir(lhScoresDir)).filter((f) => f.endsWith(".json"));
|
|
70
|
+
if (jsonFiles.length === 0) return;
|
|
71
|
+
const scores = {};
|
|
72
|
+
for (const fileName of jsonFiles) {
|
|
73
|
+
const score = await fse.readJson(path.join(lhScoresDir, fileName));
|
|
74
|
+
Object.entries(score).forEach(([k, v]) => {
|
|
75
|
+
if (!scores[k]) scores[k] = 0;
|
|
76
|
+
scores[k] += v.score;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
Object.entries(scores).forEach(([k, v]) => {
|
|
80
|
+
scores[k] = v / jsonFiles.length;
|
|
81
|
+
});
|
|
82
|
+
await writeCsvResult(reportDir, "_AVERAGE_", scores);
|
|
95
83
|
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { buildAverageCsv, getScores, writeCsvResult, writeHtmlListEntryWithRetry, writeScoresToJson };
|
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
args: [...launchOptions.args || [], `--remote-debugging-port=${port}`]
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
await use(context);
|
|
26
|
-
await context.close();
|
|
27
|
-
},
|
|
28
|
-
{ scope: "test" }
|
|
29
|
-
]
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
|
|
3
|
+
const require_constants = require("./constants-WB1XbOZm.cjs");
|
|
4
|
+
let os = require("os");
|
|
5
|
+
os = require_rolldown_runtime.__toESM(os, 1);
|
|
6
|
+
let path = require("path");
|
|
7
|
+
path = require_rolldown_runtime.__toESM(path, 1);
|
|
8
|
+
let get_port = require("get-port");
|
|
9
|
+
get_port = require_rolldown_runtime.__toESM(get_port, 1);
|
|
10
|
+
let _playwright_test = require("@playwright/test");
|
|
11
|
+
//#region src/playwrightLighthouseTest.ts
|
|
12
|
+
var playwrightLighthouseTest = _playwright_test.test.extend({
|
|
13
|
+
port: [async ({}, use) => {
|
|
14
|
+
await use(await (0, get_port.default)());
|
|
15
|
+
}, { scope: "worker" }],
|
|
16
|
+
context: [async ({ port, launchOptions }, use) => {
|
|
17
|
+
const context = await _playwright_test.chromium.launchPersistentContext(path.default.join(os.default.tmpdir(), require_constants.PW_TMP_DIR, `${Math.random()}`.replace(".", "")), { args: [...launchOptions.args || [], `--remote-debugging-port=${port}`] });
|
|
18
|
+
await use(context);
|
|
19
|
+
await context.close();
|
|
20
|
+
}, { scope: "test" }]
|
|
30
21
|
});
|
|
22
|
+
//#endregion
|
|
31
23
|
exports.playwrightLighthouseTest = playwrightLighthouseTest;
|
|
@@ -1,31 +1,18 @@
|
|
|
1
|
+
import { r as PW_TMP_DIR } from "./constants-CFLum58k.js";
|
|
1
2
|
import os from "os";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import getPort from "get-port";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
context: [
|
|
16
|
-
async ({ port, launchOptions }, use) => {
|
|
17
|
-
const context = await chromium.launchPersistentContext(
|
|
18
|
-
path.join(os.tmpdir(), PW_TMP_DIR, `${Math.random()}`.replace(".", "")),
|
|
19
|
-
{
|
|
20
|
-
args: [...launchOptions.args || [], `--remote-debugging-port=${port}`]
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
await use(context);
|
|
24
|
-
await context.close();
|
|
25
|
-
},
|
|
26
|
-
{ scope: "test" }
|
|
27
|
-
]
|
|
5
|
+
import { chromium, test } from "@playwright/test";
|
|
6
|
+
//#region src/playwrightLighthouseTest.ts
|
|
7
|
+
var playwrightLighthouseTest = test.extend({
|
|
8
|
+
port: [async ({}, use) => {
|
|
9
|
+
await use(await getPort());
|
|
10
|
+
}, { scope: "worker" }],
|
|
11
|
+
context: [async ({ port, launchOptions }, use) => {
|
|
12
|
+
const context = await chromium.launchPersistentContext(path.join(os.tmpdir(), PW_TMP_DIR, `${Math.random()}`.replace(".", "")), { args: [...launchOptions.args || [], `--remote-debugging-port=${port}`] });
|
|
13
|
+
await use(context);
|
|
14
|
+
await context.close();
|
|
15
|
+
}, { scope: "test" }]
|
|
28
16
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { playwrightLighthouseTest };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "__toESM", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return __toESM;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
await test.expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
|
|
31
|
-
}
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-D6vf50IK.cjs");
|
|
3
|
+
let fs_extra = require("fs-extra");
|
|
4
|
+
fs_extra = require_rolldown_runtime.__toESM(fs_extra, 1);
|
|
5
|
+
let _playwright_test = require("@playwright/test");
|
|
6
|
+
//#region src/storybookPlaywright.ts
|
|
7
|
+
var storybookPlaywright = {
|
|
8
|
+
getStories: (pathToStorybookIndexJson, storyFilterFn) => {
|
|
9
|
+
if (!fs_extra.default.existsSync(pathToStorybookIndexJson)) {
|
|
10
|
+
console.log(pathToStorybookIndexJson, "doesn't exist.");
|
|
11
|
+
throw new Error("Please build storybook before running tests!");
|
|
12
|
+
}
|
|
13
|
+
const storybookIndexJson = fs_extra.default.readJsonSync(pathToStorybookIndexJson);
|
|
14
|
+
const storyObject = storybookIndexJson.entries || storybookIndexJson.stories;
|
|
15
|
+
return Object.values(storyObject).filter(storyFilterFn);
|
|
16
|
+
},
|
|
17
|
+
captureScreenshot: async (story, context, screenshotOptions, options = { waitForLoadStateTimeout: 2e3 }, actionBeforeScreenshot) => {
|
|
18
|
+
const page = context.pages()[0];
|
|
19
|
+
await page.goto(`/iframe.html?id=${story.id}`);
|
|
20
|
+
await (0, _playwright_test.expect)(page.locator(".sb-show-main")).toBeVisible();
|
|
21
|
+
await (0, _playwright_test.expect)(page.locator(".sb-show-errordisplay")).not.toBeVisible();
|
|
22
|
+
try {
|
|
23
|
+
await page.waitForLoadState("networkidle", { timeout: options.waitForLoadStateTimeout });
|
|
24
|
+
} catch {}
|
|
25
|
+
if (actionBeforeScreenshot) await actionBeforeScreenshot(page);
|
|
26
|
+
await (0, _playwright_test.expect)(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
|
|
27
|
+
}
|
|
32
28
|
};
|
|
29
|
+
//#endregion
|
|
33
30
|
exports.storybookPlaywright = storybookPlaywright;
|
|
@@ -1,33 +1,27 @@
|
|
|
1
1
|
import fse from "fs-extra";
|
|
2
2
|
import { expect } from "@playwright/test";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (actionBeforeScreenshot) {
|
|
26
|
-
await actionBeforeScreenshot(page);
|
|
27
|
-
}
|
|
28
|
-
await expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
storybookPlaywright
|
|
3
|
+
//#region src/storybookPlaywright.ts
|
|
4
|
+
var storybookPlaywright = {
|
|
5
|
+
getStories: (pathToStorybookIndexJson, storyFilterFn) => {
|
|
6
|
+
if (!fse.existsSync(pathToStorybookIndexJson)) {
|
|
7
|
+
console.log(pathToStorybookIndexJson, "doesn't exist.");
|
|
8
|
+
throw new Error("Please build storybook before running tests!");
|
|
9
|
+
}
|
|
10
|
+
const storybookIndexJson = fse.readJsonSync(pathToStorybookIndexJson);
|
|
11
|
+
const storyObject = storybookIndexJson.entries || storybookIndexJson.stories;
|
|
12
|
+
return Object.values(storyObject).filter(storyFilterFn);
|
|
13
|
+
},
|
|
14
|
+
captureScreenshot: async (story, context, screenshotOptions, options = { waitForLoadStateTimeout: 2e3 }, actionBeforeScreenshot) => {
|
|
15
|
+
const page = context.pages()[0];
|
|
16
|
+
await page.goto(`/iframe.html?id=${story.id}`);
|
|
17
|
+
await expect(page.locator(".sb-show-main")).toBeVisible();
|
|
18
|
+
await expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
|
|
19
|
+
try {
|
|
20
|
+
await page.waitForLoadState("networkidle", { timeout: options.waitForLoadStateTimeout });
|
|
21
|
+
} catch {}
|
|
22
|
+
if (actionBeforeScreenshot) await actionBeforeScreenshot(page);
|
|
23
|
+
await expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
|
|
24
|
+
}
|
|
33
25
|
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { storybookPlaywright };
|