@atomicsmash/test-utils 1.0.1 → 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.d.ts CHANGED
@@ -10,6 +10,23 @@ export type AuthenticatePageFunction = ({ page }: {
10
10
  page: Page;
11
11
  }, use: (r: Page) => Promise<void>) => Promise<void>;
12
12
  export declare const playwrightProjectsConfig: PlaywrightTestConfig["projects"];
13
+ export declare const playwrightConfig: {
14
+ testDir: string;
15
+ timeout: number;
16
+ expect: {
17
+ timeout: number;
18
+ };
19
+ fullyParallel: true;
20
+ forbidOnly: boolean;
21
+ retries: number;
22
+ workers: number | undefined;
23
+ reporter: "html";
24
+ projects: import("@playwright/test").Project<import("@playwright/test").PlaywrightTestOptions & {}, import("@playwright/test").PlaywrightWorkerOptions & {}>[];
25
+ use: {
26
+ actionTimeout: number;
27
+ trace: "on-first-retry";
28
+ };
29
+ };
13
30
  export declare const getLighthouseTest: (logInUser: AuthenticatePageFunction) => import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
14
31
  authenticatedPage: Page;
15
32
  context: BrowserContext;
@@ -17,7 +34,7 @@ export declare const getLighthouseTest: (logInUser: AuthenticatePageFunction) =>
17
34
  port: number;
18
35
  }>;
19
36
  type LighthouseTestFunction = Parameters<ReturnType<typeof getLighthouseTest>>[1];
20
- export declare const doLighthouseTest: (pageToTest: PageList[number], type: "desktop" | "mobile") => LighthouseTestFunction;
37
+ export declare const doLighthouseTest: (pageToTest: PageList[number], type: "desktop" | "mobile", disableAuditLogs?: boolean) => LighthouseTestFunction;
21
38
  export declare function checkAccessibility(page: Page, { includes, excludes, }?: {
22
39
  includes?: SerialFrameSelector[];
23
40
  excludes?: SerialFrameSelector[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,IAAI,EACJ,c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AC5B,iBA6BN;AAED,eAAO,MAAM,oBAAoB;UAEP,IAAI;mBAS5B,CAAC;AACH,eAAO,MAAM,kBAAkB;uBAEqB,IAAI;mBAStD,CAAC"}
package/dist/index.js CHANGED
@@ -35,6 +35,24 @@ export const playwrightProjectsConfig = [
35
35
  grepInvert: /@lighthouse/,
36
36
  },
37
37
  ];
38
+ export const playwrightConfig = {
39
+ testDir: "./tests/e2e",
40
+ timeout: 30 * 1000,
41
+ expect: {
42
+ timeout: 10 * 1000,
43
+ },
44
+ fullyParallel: true,
45
+ forbidOnly: !!process.env.CI,
46
+ retries: process.env.CI ? 2 : 0,
47
+ workers: process.env.CI ? 1 : undefined,
48
+ reporter: "html",
49
+ /* Configure projects for major browsers */
50
+ projects: playwrightProjectsConfig,
51
+ use: {
52
+ actionTimeout: 0,
53
+ trace: "on-first-retry",
54
+ },
55
+ };
38
56
  export const getLighthouseTest = (logInUser) => {
39
57
  const lighthouseTest = base.extend({
40
58
  port: [
@@ -62,7 +80,7 @@ export const getLighthouseTest = (logInUser) => {
62
80
  lighthouseTest.describe.configure({ mode: "parallel", retries: 3 });
63
81
  return lighthouseTest;
64
82
  };
65
- export const doLighthouseTest = (pageToTest, type) => async function ({ port, authenticatedPage }) {
83
+ export const doLighthouseTest = (pageToTest, type, disableAuditLogs = false) => async function ({ port, authenticatedPage }) {
66
84
  await authenticatedPage.goto(pageToTest.url);
67
85
  await playAudit({
68
86
  page: authenticatedPage,
@@ -84,6 +102,7 @@ export const doLighthouseTest = (pageToTest, type) => async function ({ port, au
84
102
  ? lighthouseDesktopConfig
85
103
  : lighthouseMobileConfig),
86
104
  ignoreError: true,
105
+ disableLogs: disableAuditLogs,
87
106
  });
88
107
  await authenticatedPage.goto(`file://${process.cwd()}/lighthouse/latest-lighthouse-report/${pageToTest.slug ?? slugify(pageToTest.name)}-${type}.html`);
89
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomicsmash/test-utils",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "A collection of helper functions for automated testing with Playwright.",
6
6
  "keywords": [