lighthouse-reporting 1.0.0 → 1.2.0
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/index.cjs +4 -2
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -2
- package/dist/lighthouse-reporting.umd.cjs +22 -2
- package/dist/{lighthouseTest.cjs → playwrightLighthouseTest.cjs} +2 -2
- package/dist/playwrightLighthouseTest.d.ts +6 -0
- package/dist/{lighthouseTest.js → playwrightLighthouseTest.js} +2 -2
- package/dist/storybookPlaywright.cjs +24 -0
- package/dist/storybookPlaywright.d.ts +51 -0
- package/dist/storybookPlaywright.js +24 -0
- package/package.json +7 -6
- package/dist/lighthouseTest.d.ts +0 -6
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const hooks = require("./hooks.cjs");
|
|
4
4
|
const lighthouseReports = require("./lighthouseReports.cjs");
|
|
5
|
-
const
|
|
5
|
+
const playwrightLighthouseTest = require("./playwrightLighthouseTest.cjs");
|
|
6
|
+
const storybookPlaywright = require("./storybookPlaywright.cjs");
|
|
6
7
|
require("os");
|
|
7
8
|
require("path");
|
|
8
9
|
require("fs-extra");
|
|
@@ -15,4 +16,5 @@ exports.lighthouseSetup = hooks.lighthouseSetup;
|
|
|
15
16
|
exports.getScores = lighthouseReports.getScores;
|
|
16
17
|
exports.writeCsvResult = lighthouseReports.writeCsvResult;
|
|
17
18
|
exports.writeHtmlListEntryWithRetry = lighthouseReports.writeHtmlListEntryWithRetry;
|
|
18
|
-
exports.
|
|
19
|
+
exports.playwrightLighthouseTest = playwrightLighthouseTest.playwrightLighthouseTest;
|
|
20
|
+
exports.storybookPlaywright = storybookPlaywright.storybookPlaywright;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
|
-
export * from './lighthouseReports';
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './hooks.js';
|
|
2
|
+
export * from './lighthouseReports.js';
|
|
3
|
+
export * from './playwrightLighthouseTest.js';
|
|
4
|
+
export * from './storybookPlaywright.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { lighthousePlaywrightTeardown, lighthouseSetup } from "./hooks.js";
|
|
2
2
|
import { getScores, writeCsvResult, writeHtmlListEntryWithRetry } from "./lighthouseReports.js";
|
|
3
|
-
import {
|
|
3
|
+
import { playwrightLighthouseTest } from "./playwrightLighthouseTest.js";
|
|
4
|
+
import { storybookPlaywright } from "./storybookPlaywright.js";
|
|
4
5
|
import "os";
|
|
5
6
|
import "path";
|
|
6
7
|
import "fs-extra";
|
|
@@ -12,7 +13,8 @@ export {
|
|
|
12
13
|
getScores,
|
|
13
14
|
lighthousePlaywrightTeardown,
|
|
14
15
|
lighthouseSetup,
|
|
15
|
-
|
|
16
|
+
playwrightLighthouseTest,
|
|
17
|
+
storybookPlaywright,
|
|
16
18
|
writeCsvResult,
|
|
17
19
|
writeHtmlListEntryWithRetry
|
|
18
20
|
};
|
|
@@ -169,7 +169,7 @@
|
|
|
169
169
|
}
|
|
170
170
|
throw new Error("No available ports found");
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const playwrightLighthouseTest = test.test.extend({
|
|
173
173
|
port: [
|
|
174
174
|
// eslint-disable-next-line no-empty-pattern
|
|
175
175
|
async ({}, use) => {
|
|
@@ -192,10 +192,30 @@
|
|
|
192
192
|
{ scope: "test" }
|
|
193
193
|
]
|
|
194
194
|
});
|
|
195
|
+
const storybookPlaywright = {
|
|
196
|
+
getStories: (pathToStorybookIndexJson, storyFilterFn) => {
|
|
197
|
+
if (!fse.existsSync(pathToStorybookIndexJson)) {
|
|
198
|
+
console.log(pathToStorybookIndexJson, "doesn't exist.");
|
|
199
|
+
throw new Error("Please build storybook before running tests!");
|
|
200
|
+
}
|
|
201
|
+
const storybookIndexJson = fse.readJsonSync(pathToStorybookIndexJson);
|
|
202
|
+
const stories = Object.values(storybookIndexJson.entries).filter(storyFilterFn);
|
|
203
|
+
return stories;
|
|
204
|
+
},
|
|
205
|
+
captureScreenshot: async (story, context, screenshotOptions) => {
|
|
206
|
+
const page = context.pages()[0];
|
|
207
|
+
await page.goto(`/iframe.html?id=${story.id}`);
|
|
208
|
+
await test.expect(page.locator(".sb-show-main")).toBeVisible();
|
|
209
|
+
await test.expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
|
|
210
|
+
await page.waitForLoadState("networkidle");
|
|
211
|
+
await test.expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
195
214
|
exports2.getScores = getScores;
|
|
196
215
|
exports2.lighthousePlaywrightTeardown = lighthousePlaywrightTeardown;
|
|
197
216
|
exports2.lighthouseSetup = lighthouseSetup;
|
|
198
|
-
exports2.
|
|
217
|
+
exports2.playwrightLighthouseTest = playwrightLighthouseTest;
|
|
218
|
+
exports2.storybookPlaywright = storybookPlaywright;
|
|
199
219
|
exports2.writeCsvResult = writeCsvResult;
|
|
200
220
|
exports2.writeHtmlListEntryWithRetry = writeHtmlListEntryWithRetry;
|
|
201
221
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
@@ -5,7 +5,7 @@ const path = require("path");
|
|
|
5
5
|
const getPort = require("get-port");
|
|
6
6
|
const test = require("@playwright/test");
|
|
7
7
|
const constants = require("./constants-667b8033.cjs");
|
|
8
|
-
const
|
|
8
|
+
const playwrightLighthouseTest = test.test.extend({
|
|
9
9
|
port: [
|
|
10
10
|
// eslint-disable-next-line no-empty-pattern
|
|
11
11
|
async ({}, use) => {
|
|
@@ -28,4 +28,4 @@ const lighthouseTest = test.test.extend({
|
|
|
28
28
|
{ scope: "test" }
|
|
29
29
|
]
|
|
30
30
|
});
|
|
31
|
-
exports.
|
|
31
|
+
exports.playwrightLighthouseTest = playwrightLighthouseTest;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BrowserContext } from '@playwright/test';
|
|
2
|
+
export declare const playwrightLighthouseTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
|
|
3
|
+
context: BrowserContext;
|
|
4
|
+
}, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
|
|
5
|
+
port: number;
|
|
6
|
+
}>;
|
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
import getPort from "get-port";
|
|
4
4
|
import { test, chromium } from "@playwright/test";
|
|
5
5
|
import { P as PW_TMP_DIR } from "./constants-226e9774.js";
|
|
6
|
-
const
|
|
6
|
+
const playwrightLighthouseTest = test.extend({
|
|
7
7
|
port: [
|
|
8
8
|
// eslint-disable-next-line no-empty-pattern
|
|
9
9
|
async ({}, use) => {
|
|
@@ -27,5 +27,5 @@ const lighthouseTest = test.extend({
|
|
|
27
27
|
]
|
|
28
28
|
});
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
playwrightLighthouseTest
|
|
31
31
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const fse = require("fs-extra");
|
|
4
|
+
const test = require("@playwright/test");
|
|
5
|
+
const storybookPlaywright = {
|
|
6
|
+
getStories: (pathToStorybookIndexJson, storyFilterFn) => {
|
|
7
|
+
if (!fse.existsSync(pathToStorybookIndexJson)) {
|
|
8
|
+
console.log(pathToStorybookIndexJson, "doesn't exist.");
|
|
9
|
+
throw new Error("Please build storybook before running tests!");
|
|
10
|
+
}
|
|
11
|
+
const storybookIndexJson = fse.readJsonSync(pathToStorybookIndexJson);
|
|
12
|
+
const stories = Object.values(storybookIndexJson.entries).filter(storyFilterFn);
|
|
13
|
+
return stories;
|
|
14
|
+
},
|
|
15
|
+
captureScreenshot: async (story, context, screenshotOptions) => {
|
|
16
|
+
const page = context.pages()[0];
|
|
17
|
+
await page.goto(`/iframe.html?id=${story.id}`);
|
|
18
|
+
await test.expect(page.locator(".sb-show-main")).toBeVisible();
|
|
19
|
+
await test.expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
|
|
20
|
+
await page.waitForLoadState("networkidle");
|
|
21
|
+
await test.expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.storybookPlaywright = storybookPlaywright;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BrowserContext } from '@playwright/test';
|
|
2
|
+
export interface StorybookIndexStory {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
name: string;
|
|
6
|
+
importPath: string;
|
|
7
|
+
tags: Array<string>;
|
|
8
|
+
type: 'story' | 'docs';
|
|
9
|
+
}
|
|
10
|
+
type StoriesFilterFn = (story: StorybookIndexStory) => boolean;
|
|
11
|
+
export declare const storybookPlaywright: {
|
|
12
|
+
getStories: (pathToStorybookIndexJson: string, storyFilterFn: StoriesFilterFn) => StorybookIndexStory[];
|
|
13
|
+
captureScreenshot: (story: StorybookIndexStory, context: BrowserContext, screenshotOptions?: {
|
|
14
|
+
/**
|
|
15
|
+
* When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different
|
|
16
|
+
* treatment depending on their duration:
|
|
17
|
+
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
|
|
18
|
+
* - infinite animations are canceled to initial state, and then played over after the screenshot.
|
|
19
|
+
*
|
|
20
|
+
* Defaults to `"disabled"` that disables animations.
|
|
21
|
+
*/
|
|
22
|
+
animations?: 'disabled' | 'allow';
|
|
23
|
+
/**
|
|
24
|
+
* When set to `"hide"`, screenshot will hide text caret. When set to `"initial"`, text caret behavior will not be
|
|
25
|
+
* changed. Defaults to `"hide"`.
|
|
26
|
+
*/
|
|
27
|
+
caret?: 'hide' | 'initial';
|
|
28
|
+
/**
|
|
29
|
+
* An object which specifies clipping of the resulting image.
|
|
30
|
+
*/
|
|
31
|
+
clip?: {
|
|
32
|
+
/**
|
|
33
|
+
* x-coordinate of top-left corner of clip area
|
|
34
|
+
*/
|
|
35
|
+
x: number;
|
|
36
|
+
/**
|
|
37
|
+
* y-coordinate of top-left corner of clip area
|
|
38
|
+
*/
|
|
39
|
+
y: number;
|
|
40
|
+
/**
|
|
41
|
+
* width of clipping area
|
|
42
|
+
*/
|
|
43
|
+
width: number;
|
|
44
|
+
/**
|
|
45
|
+
* height of clipping area
|
|
46
|
+
*/
|
|
47
|
+
height: number;
|
|
48
|
+
};
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import fse from "fs-extra";
|
|
2
|
+
import { expect } from "@playwright/test";
|
|
3
|
+
const storybookPlaywright = {
|
|
4
|
+
getStories: (pathToStorybookIndexJson, storyFilterFn) => {
|
|
5
|
+
if (!fse.existsSync(pathToStorybookIndexJson)) {
|
|
6
|
+
console.log(pathToStorybookIndexJson, "doesn't exist.");
|
|
7
|
+
throw new Error("Please build storybook before running tests!");
|
|
8
|
+
}
|
|
9
|
+
const storybookIndexJson = fse.readJsonSync(pathToStorybookIndexJson);
|
|
10
|
+
const stories = Object.values(storybookIndexJson.entries).filter(storyFilterFn);
|
|
11
|
+
return stories;
|
|
12
|
+
},
|
|
13
|
+
captureScreenshot: async (story, context, screenshotOptions) => {
|
|
14
|
+
const page = context.pages()[0];
|
|
15
|
+
await page.goto(`/iframe.html?id=${story.id}`);
|
|
16
|
+
await expect(page.locator(".sb-show-main")).toBeVisible();
|
|
17
|
+
await expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
|
|
18
|
+
await page.waitForLoadState("networkidle");
|
|
19
|
+
await expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
storybookPlaywright
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse-reporting",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build && vite build -c vite.umd.config.ts && tsc -p ./tsconfig.build.json",
|
|
@@ -22,11 +22,12 @@
|
|
|
22
22
|
"default": "./dist/index.cjs"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
-
"
|
|
26
|
-
"@playwright/test": "1"
|
|
25
|
+
"optionalDependencies": {
|
|
26
|
+
"@playwright/test": "^1",
|
|
27
|
+
"get-port": "^6"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@playwright/test": "^1.34.
|
|
30
|
+
"@playwright/test": "^1.34.3",
|
|
30
31
|
"@types/fs-extra": "^11.0.1",
|
|
31
32
|
"@types/node": "^20.2.3",
|
|
32
33
|
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
"eslint": "^8.41.0",
|
|
35
36
|
"eslint-config-prettier": "^8.8.0",
|
|
36
37
|
"eslint-plugin-prettier": "^4.2.1",
|
|
38
|
+
"get-port": "^6.1.2",
|
|
37
39
|
"husky": "^8.0.3",
|
|
38
40
|
"npm-run-all": "^4.1.5",
|
|
39
41
|
"prettier": "^2.8.8",
|
|
@@ -43,8 +45,7 @@
|
|
|
43
45
|
"vite-plugin-static-copy": "^0.15.0"
|
|
44
46
|
},
|
|
45
47
|
"dependencies": {
|
|
46
|
-
"fs-extra": "^11.1.1"
|
|
47
|
-
"get-port": "^6.1.2"
|
|
48
|
+
"fs-extra": "^11.1.1"
|
|
48
49
|
},
|
|
49
50
|
"repository": {
|
|
50
51
|
"type": "git",
|
package/dist/lighthouseTest.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BrowserContext } from '@playwright/test';
|
|
2
|
-
export declare const lighthouseTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
|
|
3
|
-
context: BrowserContext;
|
|
4
|
-
}, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
|
|
5
|
-
port: number;
|
|
6
|
-
}>;
|