@atomicsmash/test-utils 2.0.0-beta.0 → 3.0.0-beta.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
@@ -9,7 +9,6 @@ export type PageList = {
9
9
  export type AuthenticatePageFunction = ({ page }: {
10
10
  page: Page;
11
11
  }, use: (r: Page) => Promise<void>) => Promise<void>;
12
- export declare const playwrightProjectsConfig: PlaywrightTestConfig["projects"];
13
12
  export declare const playwrightConfig: {
14
13
  testDir: string;
15
14
  timeout: number;
@@ -20,12 +19,13 @@ export declare const playwrightConfig: {
20
19
  forbidOnly: boolean;
21
20
  retries: number;
22
21
  workers: number | undefined;
23
- reporter: "dot";
24
- projects: import("@playwright/test").Project<import("@playwright/test").PlaywrightTestOptions & {}, import("@playwright/test").PlaywrightWorkerOptions & {}>[];
22
+ reporter: "github" | "dot";
25
23
  use: {
26
24
  actionTimeout: number;
27
25
  trace: "on-first-retry";
28
26
  };
27
+ snapshotDir: string;
28
+ snapshotPathTemplate: string;
29
29
  };
30
30
  export declare const getLighthouseTest: (logInUser: AuthenticatePageFunction) => import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & {
31
31
  authenticatedPage: Page;
@@ -45,5 +45,7 @@ export declare const checkPrivilegedPages: (pagesToTest: PageList) => ({ page }:
45
45
  export declare const checkForLoremIpsum: (pagesToTest: PageList) => ({ authenticatedPage }: {
46
46
  authenticatedPage: Page;
47
47
  }) => Promise<void>;
48
+ export declare function slugify(stringToSlugify: string): string;
49
+ export declare function generateProjectsForAllBrowsers(baseProject: NonNullable<PlaywrightTestConfig["projects"]>[number]): import("@playwright/test").Project<import("@playwright/test").PlaywrightTestOptions & {}, import("@playwright/test").PlaywrightWorkerOptions & {}>[];
48
50
  export {};
49
51
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src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AI,EAAE,IAAI,EACV,EACC,QAAQ,EACR,QAAQ,GACR,GAAE;IACF,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAC5B,iBAiCN;AAED,eAAO,MAAM,oBAAoB,wCAEf;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,kBAS9B,CAAC;AACH,eAAO,MAAM,kBAAkB,qDAEA;IAAE,iBAAiB,EAAE,IAAI,CAAA;CAAE,kBASxD,CAAC;AAEH,wBAAgB,OAAO,CAAC,eAAe,EAAE,MAAM,UAU9C;AAED,wBAAgB,8BAA8B,CAC7C,WAAW,EAAE,WAAW,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,wJAqDlE"}
package/dist/index.js CHANGED
@@ -7,34 +7,6 @@ import lighthouseDesktopConfig from "lighthouse/core/config/lr-desktop-config.js
7
7
  import lighthouseMobileConfig from "lighthouse/core/config/lr-mobile-config.js";
8
8
  import { playAudit } from "playwright-lighthouse";
9
9
  const { expect } = base;
10
- export const playwrightProjectsConfig = [
11
- {
12
- name: "chromium",
13
- use: { ...devices["Desktop Chrome"] },
14
- grepInvert: /@mobile @lighthouse/,
15
- },
16
- {
17
- name: "firefox",
18
- use: { ...devices["Desktop Firefox"] },
19
- grepInvert: /@lighthouse/,
20
- },
21
- {
22
- name: "webkit",
23
- use: { ...devices["Desktop Safari"] },
24
- grepInvert: /@lighthouse/,
25
- },
26
- /* Test against mobile viewports. */
27
- {
28
- name: "Mobile Chrome",
29
- use: { ...devices["Pixel 5"] },
30
- grepInvert: /@desktop @lighthouse/,
31
- },
32
- {
33
- name: "Mobile Safari",
34
- use: { ...devices["iPhone 12"] },
35
- grepInvert: /@lighthouse/,
36
- },
37
- ];
38
10
  export const playwrightConfig = {
39
11
  testDir: "./tests/e2e",
40
12
  timeout: 30 * 1000,
@@ -45,19 +17,18 @@ export const playwrightConfig = {
45
17
  forbidOnly: !!process.env.CI,
46
18
  retries: process.env.CI ? 2 : 0,
47
19
  workers: process.env.CI ? 1 : undefined,
48
- reporter: "dot",
49
- /* Configure projects for major browsers */
50
- projects: playwrightProjectsConfig,
20
+ reporter: process.env.CI ? "github" : "dot",
51
21
  use: {
52
22
  actionTimeout: 0,
53
23
  trace: "on-first-retry",
54
24
  },
25
+ snapshotDir: "./screenshots",
26
+ snapshotPathTemplate: "{snapshotDir}/{platform}/{testFileName}-snapshots/{arg}{ext}",
55
27
  };
56
28
  export const getLighthouseTest = (logInUser) => {
57
29
  const lighthouseTest = base.extend({
58
30
  port: [
59
- // eslint-disable-next-line no-empty-pattern
60
- async ({}, use) => {
31
+ async (_unused, use) => {
61
32
  // Assign a unique port for each playwright worker to support parallel tests
62
33
  const port = await getPort();
63
34
  await use(port);
@@ -149,7 +120,7 @@ export const checkForLoremIpsum = (pagesToTest) => async ({ authenticatedPage })
149
120
  });
150
121
  }
151
122
  };
152
- function slugify(stringToSlugify) {
123
+ export function slugify(stringToSlugify) {
153
124
  // REGEX_1: Match any character that isn't alphanumeric, underscore, whitespace and underscore
154
125
  // REGEX_2: Match any character that is underscore, whitespace and underscore
155
126
  // REGEX_3: Match any hyphens at the start or the end of the string
@@ -160,3 +131,56 @@ function slugify(stringToSlugify) {
160
131
  .replace(/[\s_-]+/g, "-")
161
132
  .replace(/^-+|(?<!-)-+$/g, "");
162
133
  }
134
+ export function generateProjectsForAllBrowsers(baseProject) {
135
+ const projects = [];
136
+ for (const browser of [
137
+ {
138
+ name: `Chrome`,
139
+ use: {
140
+ ...devices["Desktop Chrome"],
141
+ viewport: { width: 2566, height: 1080 },
142
+ },
143
+ grepInvert: /@mobile/, // i.e. don't run tests with these tags
144
+ },
145
+ {
146
+ name: `Firefox`,
147
+ use: {
148
+ ...devices["Desktop Firefox"],
149
+ viewport: { width: 1920, height: 1080 },
150
+ },
151
+ grepInvert: /@mobile|@lighthouse/,
152
+ },
153
+ {
154
+ name: `Safari`,
155
+ use: {
156
+ ...devices["Desktop Safari"],
157
+ viewport: { width: 1280, height: 720 },
158
+ },
159
+ grepInvert: /@mobile|@lighthouse/,
160
+ },
161
+ {
162
+ name: `Chrome_mobile`,
163
+ use: { ...devices["Pixel 5"] },
164
+ grepInvert: /@desktop/,
165
+ },
166
+ {
167
+ name: `Safari_mobile`,
168
+ use: { ...devices["iPhone 12"] },
169
+ grepInvert: /@desktop|@lighthouse/,
170
+ },
171
+ ]) {
172
+ projects.push({
173
+ ...baseProject,
174
+ name: `${baseProject.name}__${browser.name}`,
175
+ use: {
176
+ ...baseProject.use,
177
+ ...browser.use,
178
+ },
179
+ grepInvert: [
180
+ ...[baseProject.grepInvert].flat(1),
181
+ ...[browser.grepInvert].flat(1),
182
+ ].filter((value) => value !== undefined),
183
+ });
184
+ }
185
+ return projects;
186
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atomicsmash/test-utils",
3
- "version": "2.0.0-beta.0",
3
+ "version": "3.0.0-beta.0",
4
4
  "type": "module",
5
5
  "description": "A collection of helper functions for automated testing with Playwright.",
6
6
  "keywords": [
@@ -42,11 +42,11 @@
42
42
  "lint:types": "tsc"
43
43
  },
44
44
  "peerDependencies": {
45
- "@playwright/test": "^1.46.0",
45
+ "@playwright/test": "^1.48.2",
46
46
  "cross-env": "^7.0.3"
47
47
  },
48
48
  "dependencies": {
49
- "@axe-core/playwright": "^4.9.1",
49
+ "@axe-core/playwright": "^4.10.0",
50
50
  "get-port": "^7.1.0",
51
51
  "playwright-lighthouse": "^4.0.0"
52
52
  }