@empiricalrun/playwright-utils 0.14.3 → 0.14.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.14.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ff77220]
8
+ - @empiricalrun/r2-uploader@0.3.4
9
+
3
10
  ## 0.14.3
4
11
 
5
12
  ### Patch Changes
package/docs/auth.md CHANGED
@@ -53,16 +53,13 @@ projects: [
53
53
  - Create `TestOptions` in `fixtures.ts` that has all options that can be configured
54
54
  - Configure fixtures and `playwright.config.ts` to use `TestOptions` type
55
55
  - Set the `userContext` in the project.use field
56
+ - For setup projects, add `userContext` only
57
+ - For test/teardown projects, add `userContext` and `storageState` both
56
58
 
57
59
  ```ts
58
60
  // fixtures.ts
59
61
  import { baseTestFixture } from "@empiricalrun/playwright-utils/test";
60
- import { UserContext } from "./test-data";
61
-
62
- export type UserContext = {
63
- key: string;
64
- // other fields
65
- }
62
+ import { UserContext, primaryUser } from "./test-data";
66
63
 
67
64
  export type TestOptions = {
68
65
  userContext: UserContext;
@@ -76,17 +73,44 @@ export const test = baseTestFixture(base).extend<TestOptions>({
76
73
  ```ts
77
74
  // playwright.config.ts
78
75
  import { defineConfig } from "@playwright/test";
79
- import { someTypeOfUser } from "./test-data";
76
+ import { AuthStore } from "@empiricalrun/playwright-utils";
77
+ import { TestOptions } from "./tests/fixtures";
78
+ import { someTypeOfUser } from "./tests/test-data";
80
79
 
81
80
  export default defineConfig<TestOptions>({
82
81
  ...baseConfig,
83
82
  projects: [
83
+ {
84
+ name: "setup",
85
+ use: {
86
+ // NOTE: Don't send storageState to setup
87
+ // Playwright will fail attempting to load non-existent file
88
+ // AuthStore finds it own it's own
89
+ userContext: someTypeOfUser
90
+ },
91
+ },
84
92
  {
85
93
  name: "chromium",
86
94
  use: {
87
95
  userContext: someTypeOfUser
96
+ storageState: AuthStore.location(someTypeOfUser)
88
97
  },
89
98
  },
90
99
  ],
91
100
  });
92
101
  ```
102
+
103
+ ## Structuring tests across projects
104
+
105
+ Structure tests based on which user context they depend on
106
+ - If 2 tests depend on 2 different user contexts, they will be in 2 different projects
107
+
108
+ ### Multiplayer
109
+
110
+ If a test requires 2 user context (multi-user scenarios), then
111
+ - define user contexts for both the users
112
+ - for sequential execution (admin does foo, user does bar)
113
+ - use `page` for the admin, and then login on the same page with the other user context
114
+ - for parallel execution (host and guest join room together)
115
+ - create 2 pages in the fixtures: `hostPage`, `guestPage` belonging to 2 different browser contexts
116
+ - in the fixture, use AuthStore to login if required
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.14.3",
3
+ "version": "0.14.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -39,7 +39,7 @@
39
39
  "playwright-extra": "^4.3.6",
40
40
  "puppeteer-extra-plugin-recaptcha": "^3.6.8",
41
41
  "@empiricalrun/llm": "^0.9.4",
42
- "@empiricalrun/r2-uploader": "^0.3.3"
42
+ "@empiricalrun/r2-uploader": "^0.3.4"
43
43
  },
44
44
  "scripts": {
45
45
  "dev": "tsc --build --watch",