lighthouse-reporting 1.6.2 → 1.6.4
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 +2 -0
- package/dist/hooks.cjs +3 -2
- package/dist/hooks.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/lighthouse-reporting.umd.cjs +5 -4
- package/dist/lighthouseReports.cjs +3 -3
- package/dist/lighthouseReports.d.ts +3 -5
- package/dist/lighthouseReports.js +3 -3
- package/dist/playwrightLighthouseTest.cjs +1 -1
- package/dist/playwrightLighthouseTest.js +1 -1
- package/package.json +14 -14
- /package/dist/{constants-226e9774.js → constants-9b_WPkRp.js} +0 -0
- /package/dist/{constants-667b8033.cjs → constants-PDApvt-A.cjs} +0 -0
package/README.md
CHANGED
|
@@ -47,6 +47,7 @@ lighthousePages.forEach(({ name, po, thresholds, swimlanes }) => {
|
|
|
47
47
|
// to let playwright initialize context!
|
|
48
48
|
context // this is enough to make the test work
|
|
49
49
|
|
|
50
|
+
// note: importing LighthouseResult is not needed since playwright-lighthouse release after v3.2.5 (not including)
|
|
50
51
|
const result: LighthouseResult = await playAudit({
|
|
51
52
|
url: baseURL + po.getPath('123'),
|
|
52
53
|
port,
|
|
@@ -140,6 +141,7 @@ const runLighthouse = async (story: StorybookIndexStory, context: BrowserContext
|
|
|
140
141
|
// const page = context.pages()[0]
|
|
141
142
|
// await page.goto(`/iframe.html?id=${story.id}`)
|
|
142
143
|
|
|
144
|
+
// note: importing LighthouseResult is not needed since playwright-lighthouse release after v3.2.5 (not including)
|
|
143
145
|
const result: LighthouseResult = await playAudit({
|
|
144
146
|
url: baseURL + `/iframe.html?id=${story.id}`,
|
|
145
147
|
// page, // alternatevely, path the page instead of the `url`
|
package/dist/hooks.cjs
CHANGED
|
@@ -4,10 +4,11 @@ const os = require("os");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const fse = require("fs-extra");
|
|
6
6
|
const url = require("url");
|
|
7
|
-
const constants = require("./constants-
|
|
7
|
+
const constants = require("./constants-PDApvt-A.cjs");
|
|
8
|
+
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
8
9
|
let dirname;
|
|
9
10
|
if (typeof __dirname !== "string") {
|
|
10
|
-
const filename = url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href :
|
|
11
|
+
const filename = url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.src || new URL("hooks.cjs", document.baseURI).href);
|
|
11
12
|
dirname = path.dirname(filename);
|
|
12
13
|
} else {
|
|
13
14
|
dirname = __dirname;
|
package/dist/hooks.js
CHANGED
|
@@ -2,7 +2,7 @@ import os from "os";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fse from "fs-extra";
|
|
4
4
|
import url from "url";
|
|
5
|
-
import { L as LH_OUT_DIR, I as INDEX_HTML, P as PW_TMP_DIR } from "./constants-
|
|
5
|
+
import { L as LH_OUT_DIR, I as INDEX_HTML, P as PW_TMP_DIR } from "./constants-9b_WPkRp.js";
|
|
6
6
|
let dirname;
|
|
7
7
|
if (typeof __dirname !== "string") {
|
|
8
8
|
const filename = url.fileURLToPath(import.meta.url);
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,7 @@ require("os");
|
|
|
8
8
|
require("path");
|
|
9
9
|
require("fs-extra");
|
|
10
10
|
require("url");
|
|
11
|
-
require("./constants-
|
|
11
|
+
require("./constants-PDApvt-A.cjs");
|
|
12
12
|
require("get-port");
|
|
13
13
|
require("@playwright/test");
|
|
14
14
|
exports.lighthousePlaywrightTeardown = hooks.lighthousePlaywrightTeardown;
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("os"), require("path"), require("fs-extra"), require("url"), require("net"), require("@playwright/test")) : typeof define === "function" && define.amd ? define(["exports", "os", "path", "fs-extra", "url", "net", "@playwright/test"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.lh_rep = {}, global.os, global.path, global.fse, global.url, global.net, global.test));
|
|
3
3
|
})(this, function(exports2, os, path, fse, url, net, test) {
|
|
4
4
|
"use strict";
|
|
5
|
+
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
5
6
|
const INDEX_HTML = "index.html";
|
|
6
7
|
const LH_OUT_DIR = "lighthouse";
|
|
7
8
|
const PW_TMP_DIR = "pwlh";
|
|
8
9
|
let dirname;
|
|
9
10
|
if (typeof __dirname !== "string") {
|
|
10
|
-
const filename = url.fileURLToPath(typeof document === "undefined" && typeof location === "undefined" ? require("url").pathToFileURL(__filename).href : typeof document === "undefined" ? location.href :
|
|
11
|
+
const filename = url.fileURLToPath(typeof document === "undefined" && typeof location === "undefined" ? require("url").pathToFileURL(__filename).href : typeof document === "undefined" ? location.href : _documentCurrentScript && _documentCurrentScript.src || new URL("lighthouse-reporting.umd.cjs", document.baseURI).href);
|
|
11
12
|
dirname = path.dirname(filename);
|
|
12
13
|
} else {
|
|
13
14
|
dirname = __dirname;
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
}
|
|
58
59
|
throw error;
|
|
59
60
|
};
|
|
60
|
-
const getScores = (result) => Object.entries(result.lhr.categories).reduce(
|
|
61
|
+
const getScores = (result) => Object.entries(result.lhr.categories).filter((c) => typeof c[1].score === "number").reduce(
|
|
61
62
|
(prev, [key, c]) => {
|
|
62
63
|
prev[key] = Math.floor(c.score * 100);
|
|
63
64
|
return prev;
|
|
@@ -72,12 +73,12 @@
|
|
|
72
73
|
},
|
|
73
74
|
{}
|
|
74
75
|
);
|
|
75
|
-
const accessibilityViolations = result.artifacts.Accessibility.violations.map((v) => {
|
|
76
|
+
const accessibilityViolations = result.artifacts.Accessibility ? result.artifacts.Accessibility.violations.map((v) => {
|
|
76
77
|
return {
|
|
77
78
|
title: result.lhr.audits[v.id].title,
|
|
78
79
|
nodes: v.nodes.length
|
|
79
80
|
};
|
|
80
|
-
});
|
|
81
|
+
}) : [];
|
|
81
82
|
if (accessibilityViolations.length > 0) {
|
|
82
83
|
json.accessibility.issues = accessibilityViolations;
|
|
83
84
|
}
|
|
@@ -38,7 +38,7 @@ const writeHtmlListEntryWithRetry = async (htmlFilePath, name, scores, threshold
|
|
|
38
38
|
}
|
|
39
39
|
throw error;
|
|
40
40
|
};
|
|
41
|
-
const getScores = (result) => Object.entries(result.lhr.categories).reduce(
|
|
41
|
+
const getScores = (result) => Object.entries(result.lhr.categories).filter((c) => typeof c[1].score === "number").reduce(
|
|
42
42
|
(prev, [key, c]) => {
|
|
43
43
|
prev[key] = Math.floor(c.score * 100);
|
|
44
44
|
return prev;
|
|
@@ -53,12 +53,12 @@ const writeScoresToJson = async (lhScoresDir, name, scores, result) => {
|
|
|
53
53
|
},
|
|
54
54
|
{}
|
|
55
55
|
);
|
|
56
|
-
const accessibilityViolations = result.artifacts.Accessibility.violations.map((v) => {
|
|
56
|
+
const accessibilityViolations = result.artifacts.Accessibility ? result.artifacts.Accessibility.violations.map((v) => {
|
|
57
57
|
return {
|
|
58
58
|
title: result.lhr.audits[v.id].title,
|
|
59
59
|
nodes: v.nodes.length
|
|
60
60
|
};
|
|
61
|
-
});
|
|
61
|
+
}) : [];
|
|
62
62
|
if (accessibilityViolations.length > 0) {
|
|
63
63
|
json.accessibility.issues = accessibilityViolations;
|
|
64
64
|
}
|
|
@@ -2,9 +2,7 @@ interface NodeDetails {
|
|
|
2
2
|
lhId: string;
|
|
3
3
|
devtoolsNodePath: string;
|
|
4
4
|
selector: string;
|
|
5
|
-
|
|
6
|
-
[k: string]: number;
|
|
7
|
-
};
|
|
5
|
+
boundingRect: unknown;
|
|
8
6
|
snippet: string;
|
|
9
7
|
nodeLabel: string;
|
|
10
8
|
}
|
|
@@ -28,7 +26,7 @@ export interface LighthouseResult {
|
|
|
28
26
|
lhr: {
|
|
29
27
|
categories: {
|
|
30
28
|
[k: string]: {
|
|
31
|
-
score: number;
|
|
29
|
+
score: number | null;
|
|
32
30
|
};
|
|
33
31
|
};
|
|
34
32
|
audits: {
|
|
@@ -38,7 +36,7 @@ export interface LighthouseResult {
|
|
|
38
36
|
};
|
|
39
37
|
};
|
|
40
38
|
artifacts: {
|
|
41
|
-
Accessibility
|
|
39
|
+
Accessibility?: {
|
|
42
40
|
violations: Array<AxeRuleResult>;
|
|
43
41
|
};
|
|
44
42
|
};
|
|
@@ -36,7 +36,7 @@ const writeHtmlListEntryWithRetry = async (htmlFilePath, name, scores, threshold
|
|
|
36
36
|
}
|
|
37
37
|
throw error;
|
|
38
38
|
};
|
|
39
|
-
const getScores = (result) => Object.entries(result.lhr.categories).reduce(
|
|
39
|
+
const getScores = (result) => Object.entries(result.lhr.categories).filter((c) => typeof c[1].score === "number").reduce(
|
|
40
40
|
(prev, [key, c]) => {
|
|
41
41
|
prev[key] = Math.floor(c.score * 100);
|
|
42
42
|
return prev;
|
|
@@ -51,12 +51,12 @@ const writeScoresToJson = async (lhScoresDir, name, scores, result) => {
|
|
|
51
51
|
},
|
|
52
52
|
{}
|
|
53
53
|
);
|
|
54
|
-
const accessibilityViolations = result.artifacts.Accessibility.violations.map((v) => {
|
|
54
|
+
const accessibilityViolations = result.artifacts.Accessibility ? result.artifacts.Accessibility.violations.map((v) => {
|
|
55
55
|
return {
|
|
56
56
|
title: result.lhr.audits[v.id].title,
|
|
57
57
|
nodes: v.nodes.length
|
|
58
58
|
};
|
|
59
|
-
});
|
|
59
|
+
}) : [];
|
|
60
60
|
if (accessibilityViolations.length > 0) {
|
|
61
61
|
json.accessibility.issues = accessibilityViolations;
|
|
62
62
|
}
|
|
@@ -4,7 +4,7 @@ const os = require("os");
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const getPort = require("get-port");
|
|
6
6
|
const test = require("@playwright/test");
|
|
7
|
-
const constants = require("./constants-
|
|
7
|
+
const constants = require("./constants-PDApvt-A.cjs");
|
|
8
8
|
const playwrightLighthouseTest = test.test.extend({
|
|
9
9
|
port: [
|
|
10
10
|
// eslint-disable-next-line no-empty-pattern
|
|
@@ -2,7 +2,7 @@ import os from "os";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import getPort from "get-port";
|
|
4
4
|
import { test, chromium } from "@playwright/test";
|
|
5
|
-
import { P as PW_TMP_DIR } from "./constants-
|
|
5
|
+
import { P as PW_TMP_DIR } from "./constants-9b_WPkRp.js";
|
|
6
6
|
const playwrightLighthouseTest = test.extend({
|
|
7
7
|
port: [
|
|
8
8
|
// eslint-disable-next-line no-empty-pattern
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse-reporting",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build && vite build -c vite.umd.config.ts && tsc -p ./tsconfig.build.json",
|
|
@@ -29,24 +29,24 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@playwright/test": "^1.34.3",
|
|
32
|
-
"@types/fs-extra": "^11.0.
|
|
33
|
-
"@types/node": "^20.
|
|
34
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
35
|
-
"@typescript-eslint/parser": "^6.
|
|
36
|
-
"eslint": "^8.
|
|
37
|
-
"eslint-config-prettier": "^9.
|
|
38
|
-
"eslint-plugin-prettier": "^5.
|
|
32
|
+
"@types/fs-extra": "^11.0.4",
|
|
33
|
+
"@types/node": "^20.10.8",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
35
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
36
|
+
"eslint": "^8.56.0",
|
|
37
|
+
"eslint-config-prettier": "^9.1.0",
|
|
38
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
39
39
|
"get-port": "^7.0.0",
|
|
40
40
|
"husky": "^8.0.3",
|
|
41
41
|
"npm-run-all": "^4.1.5",
|
|
42
|
-
"prettier": "^3.
|
|
43
|
-
"semantic-release": "^
|
|
44
|
-
"typescript": "^5.
|
|
45
|
-
"vite": "^
|
|
46
|
-
"vite-plugin-static-copy": "^0.
|
|
42
|
+
"prettier": "^3.1.1",
|
|
43
|
+
"semantic-release": "^22.0.12",
|
|
44
|
+
"typescript": "^5.3.3",
|
|
45
|
+
"vite": "^5.0.11",
|
|
46
|
+
"vite-plugin-static-copy": "^1.0.0"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"fs-extra": "^11.
|
|
49
|
+
"fs-extra": "^11.2.0"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|
|
File without changes
|
|
File without changes
|