lighthouse-reporting 1.5.0 → 1.6.1

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.
@@ -243,12 +243,17 @@
243
243
  const stories = Object.values(storyObject).filter(storyFilterFn);
244
244
  return stories;
245
245
  },
246
- captureScreenshot: async (story, context, screenshotOptions, actionBeforeScreenshot) => {
246
+ captureScreenshot: async (story, context, screenshotOptions, options = {
247
+ waitForLoadStateTimeout: 2e3
248
+ }, actionBeforeScreenshot) => {
247
249
  const page = context.pages()[0];
248
250
  await page.goto(`/iframe.html?id=${story.id}`);
249
251
  await test.expect(page.locator(".sb-show-main")).toBeVisible();
250
252
  await test.expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
251
- await page.waitForLoadState("networkidle");
253
+ try {
254
+ await page.waitForLoadState("networkidle", { timeout: options.waitForLoadStateTimeout });
255
+ } catch {
256
+ }
252
257
  if (actionBeforeScreenshot) {
253
258
  await actionBeforeScreenshot(page);
254
259
  }
@@ -13,12 +13,17 @@ const storybookPlaywright = {
13
13
  const stories = Object.values(storyObject).filter(storyFilterFn);
14
14
  return stories;
15
15
  },
16
- captureScreenshot: async (story, context, screenshotOptions, actionBeforeScreenshot) => {
16
+ captureScreenshot: async (story, context, screenshotOptions, options = {
17
+ waitForLoadStateTimeout: 2e3
18
+ }, actionBeforeScreenshot) => {
17
19
  const page = context.pages()[0];
18
20
  await page.goto(`/iframe.html?id=${story.id}`);
19
21
  await test.expect(page.locator(".sb-show-main")).toBeVisible();
20
22
  await test.expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
21
- await page.waitForLoadState("networkidle");
23
+ try {
24
+ await page.waitForLoadState("networkidle", { timeout: options.waitForLoadStateTimeout });
25
+ } catch {
26
+ }
22
27
  if (actionBeforeScreenshot) {
23
28
  await actionBeforeScreenshot(page);
24
29
  }
@@ -26,9 +26,8 @@ export interface StorybookStoriesStory {
26
26
  fileName: string;
27
27
  };
28
28
  }
29
- type StoriesFilterFn = <V7 = true>(story: V7 extends true ? StorybookIndexStory : StorybookStoriesStory) => boolean;
30
29
  export declare const storybookPlaywright: {
31
- getStories: (pathToStorybookIndexJson: string, storyFilterFn: StoriesFilterFn) => StorybookIndexStory[];
30
+ getStories: <V7 = true>(pathToStorybookIndexJson: string, storyFilterFn: (story: V7 extends true ? StorybookIndexStory : StorybookStoriesStory) => boolean) => StorybookIndexStory[];
32
31
  captureScreenshot: (story: StorybookIndexStory, context: BrowserContext, screenshotOptions?: {
33
32
  /**
34
33
  * When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different
@@ -108,6 +107,7 @@ export declare const storybookPlaywright: {
108
107
  * Time to retry the assertion for. Defaults to `timeout` in `TestConfig.expect`.
109
108
  */
110
109
  timeout?: number;
110
+ }, options?: {
111
+ waitForLoadStateTimeout: number;
111
112
  }, actionBeforeScreenshot?: ((page: Page) => Promise<void>) | undefined) => Promise<void>;
112
113
  };
113
- export {};
@@ -11,12 +11,17 @@ const storybookPlaywright = {
11
11
  const stories = Object.values(storyObject).filter(storyFilterFn);
12
12
  return stories;
13
13
  },
14
- captureScreenshot: async (story, context, screenshotOptions, actionBeforeScreenshot) => {
14
+ captureScreenshot: async (story, context, screenshotOptions, options = {
15
+ waitForLoadStateTimeout: 2e3
16
+ }, actionBeforeScreenshot) => {
15
17
  const page = context.pages()[0];
16
18
  await page.goto(`/iframe.html?id=${story.id}`);
17
19
  await expect(page.locator(".sb-show-main")).toBeVisible();
18
20
  await expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
19
- await page.waitForLoadState("networkidle");
21
+ try {
22
+ await page.waitForLoadState("networkidle", { timeout: options.waitForLoadStateTimeout });
23
+ } catch {
24
+ }
20
25
  if (actionBeforeScreenshot) {
21
26
  await actionBeforeScreenshot(page);
22
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse-reporting",
3
- "version": "1.5.0",
3
+ "version": "1.6.1",
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,9 +29,9 @@
29
29
  "devDependencies": {
30
30
  "@playwright/test": "^1.34.3",
31
31
  "@types/fs-extra": "^11.0.1",
32
- "@types/node": "^20.3.1",
33
- "@typescript-eslint/eslint-plugin": "^5.60.0",
34
- "@typescript-eslint/parser": "^5.60.0",
32
+ "@types/node": "^20.3.2",
33
+ "@typescript-eslint/eslint-plugin": "^5.60.1",
34
+ "@typescript-eslint/parser": "^5.60.1",
35
35
  "eslint": "^8.43.0",
36
36
  "eslint-config-prettier": "^8.8.0",
37
37
  "eslint-plugin-prettier": "^4.2.1",
@@ -39,8 +39,8 @@
39
39
  "husky": "^8.0.3",
40
40
  "npm-run-all": "^4.1.5",
41
41
  "prettier": "^2.8.8",
42
- "semantic-release": "^21.0.5",
43
- "typescript": "^5.1.3",
42
+ "semantic-release": "^21.0.6",
43
+ "typescript": "^5.1.5",
44
44
  "vite": "^4.3.9",
45
45
  "vite-plugin-static-copy": "^0.16.0"
46
46
  },