lighthouse-reporting 1.1.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.
@@ -202,13 +202,13 @@
202
202
  const stories = Object.values(storybookIndexJson.entries).filter(storyFilterFn);
203
203
  return stories;
204
204
  },
205
- captureScreenshot: async (story, context) => {
205
+ captureScreenshot: async (story, context, screenshotOptions) => {
206
206
  const page = context.pages()[0];
207
207
  await page.goto(`/iframe.html?id=${story.id}`);
208
208
  await test.expect(page.locator(".sb-show-main")).toBeVisible();
209
209
  await test.expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
210
210
  await page.waitForLoadState("networkidle");
211
- await test.expect(page).toHaveScreenshot(`${story.id}.png`);
211
+ await test.expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
212
212
  }
213
213
  };
214
214
  exports2.getScores = getScores;
@@ -1,4 +1,4 @@
1
- import type { BrowserContext } from '@playwright/test';
1
+ import { BrowserContext } from '@playwright/test';
2
2
  export declare const playwrightLighthouseTest: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
3
3
  context: BrowserContext;
4
4
  }, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & {
@@ -12,13 +12,13 @@ const storybookPlaywright = {
12
12
  const stories = Object.values(storybookIndexJson.entries).filter(storyFilterFn);
13
13
  return stories;
14
14
  },
15
- captureScreenshot: async (story, context) => {
15
+ captureScreenshot: async (story, context, screenshotOptions) => {
16
16
  const page = context.pages()[0];
17
17
  await page.goto(`/iframe.html?id=${story.id}`);
18
18
  await test.expect(page.locator(".sb-show-main")).toBeVisible();
19
19
  await test.expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
20
20
  await page.waitForLoadState("networkidle");
21
- await test.expect(page).toHaveScreenshot(`${story.id}.png`);
21
+ await test.expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
22
22
  }
23
23
  };
24
24
  exports.storybookPlaywright = storybookPlaywright;
@@ -1,4 +1,4 @@
1
- import type { BrowserContext } from '@playwright/test';
1
+ import { BrowserContext } from '@playwright/test';
2
2
  export interface StorybookIndexStory {
3
3
  id: string;
4
4
  title: string;
@@ -10,6 +10,42 @@ export interface StorybookIndexStory {
10
10
  type StoriesFilterFn = (story: StorybookIndexStory) => boolean;
11
11
  export declare const storybookPlaywright: {
12
12
  getStories: (pathToStorybookIndexJson: string, storyFilterFn: StoriesFilterFn) => StorybookIndexStory[];
13
- captureScreenshot: (story: StorybookIndexStory, context: BrowserContext) => Promise<void>;
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>;
14
50
  };
15
51
  export {};
@@ -10,13 +10,13 @@ const storybookPlaywright = {
10
10
  const stories = Object.values(storybookIndexJson.entries).filter(storyFilterFn);
11
11
  return stories;
12
12
  },
13
- captureScreenshot: async (story, context) => {
13
+ captureScreenshot: async (story, context, screenshotOptions) => {
14
14
  const page = context.pages()[0];
15
15
  await page.goto(`/iframe.html?id=${story.id}`);
16
16
  await expect(page.locator(".sb-show-main")).toBeVisible();
17
17
  await expect(page.locator(".sb-show-errordisplay")).not.toBeVisible();
18
18
  await page.waitForLoadState("networkidle");
19
- await expect(page).toHaveScreenshot(`${story.id}.png`);
19
+ await expect(page).toHaveScreenshot(`${story.id}.png`, screenshotOptions);
20
20
  }
21
21
  };
22
22
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lighthouse-reporting",
3
- "version": "1.1.0",
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",
@@ -27,7 +27,7 @@
27
27
  "get-port": "^6"
28
28
  },
29
29
  "devDependencies": {
30
- "@playwright/test": "^1.34.2",
30
+ "@playwright/test": "^1.34.3",
31
31
  "@types/fs-extra": "^11.0.1",
32
32
  "@types/node": "^20.2.3",
33
33
  "@typescript-eslint/eslint-plugin": "^5.59.7",
@@ -35,6 +35,7 @@
35
35
  "eslint": "^8.41.0",
36
36
  "eslint-config-prettier": "^8.8.0",
37
37
  "eslint-plugin-prettier": "^4.2.1",
38
+ "get-port": "^6.1.2",
38
39
  "husky": "^8.0.3",
39
40
  "npm-run-all": "^4.1.5",
40
41
  "prettier": "^2.8.8",