pomwright 0.0.8 → 1.0.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.
@@ -0,0 +1,82 @@
1
+ {
2
+ "Playwright Import": {
3
+ "prefix": "pw-import",
4
+ "body": [
5
+ "import { test, expect } from \"@fixtures/$1\";"
6
+ ],
7
+ "description": "Import Playwright Test through our Fixtures"
8
+ },
9
+ "Playwright Describe": {
10
+ "prefix": "pw-describe",
11
+ "body": [
12
+ "test.describe(\"$1\", () => {",
13
+ " $2",
14
+ "});"
15
+ ],
16
+ "description": "Playwright Test describe block"
17
+ },
18
+ "Playwright Test": {
19
+ "prefix": "pw-test",
20
+ "body": [
21
+ "test(\"$1\", async ({ $2 }) => {",
22
+ " $3",
23
+ "});"
24
+ ],
25
+ "description": "Playwright Test test block"
26
+ },
27
+ "Playwright Step": {
28
+ "prefix": "pw-step",
29
+ "body": [
30
+ "await test.step(`${$1.pocName}: $2`, async () => {",
31
+ " $3",
32
+ "});"
33
+ ],
34
+ "description": "Playwright Test step block"
35
+ },
36
+ "Playwright Use": {
37
+ "prefix": "pw-use",
38
+ "body": [
39
+ "test.use({",
40
+ " $1",
41
+ "});"
42
+ ],
43
+ "description": "Playwright Test use block"
44
+ },
45
+ "Playwright beforeEach": {
46
+ "prefix": "pw-beforeEach",
47
+ "body": [
48
+ "test.beforeEach(async ({ $1 }) => {",
49
+ " $2",
50
+ "});"
51
+ ],
52
+ "description": "Playwright Test beforeEach block"
53
+ },
54
+ "Playwright afterEach": {
55
+ "prefix": "pw-afterEach",
56
+ "body": [
57
+ "test.afterEach(async ({ $1 }) => {",
58
+ " $2",
59
+ "});"
60
+ ],
61
+ "description": "Playwright Test afterEach block"
62
+ },
63
+ "Playwright beforeAll": {
64
+ "prefix": "pw-beforeAll",
65
+ "body": [
66
+ "test.beforeAll(async ({ $1 }) => {",
67
+ " $2",
68
+ "});"
69
+ ],
70
+ "description": "Playwright Test beforeAll block"
71
+ },
72
+ "Playwright afterAll": {
73
+ "prefix": "pw-afterAll",
74
+ "body": [
75
+ "test.afterAll(async ({ $1 }) => {",
76
+ " $2",
77
+ "});"
78
+ ],
79
+ "description": "Playwright Test afterAll block"
80
+ }
81
+ }
82
+
@@ -1,3 +1,4 @@
1
1
  {
2
- "editor.defaultFormatter": "biomejs.biome"
2
+ "editor.defaultFormatter": "biomejs.biome",
3
+ "editor.formatOnSave": true
3
4
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # pomwright
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 130784f: BREAKING: The following index.ts exports have been renamed:
8
+
9
+ - "POMWright" changed to "BasePage"
10
+ - "POMWrightTestFixture" changed to "test"
11
+ - "POMWrightLogger" changed to "PlaywrightReportLogger"
12
+ - "POMWrightGetLocatorBase" changed to "GetLocatorBase"
13
+ - "POMWrightApi" changed to "BaseApi"
14
+
15
+ Documentation updated
16
+
17
+ README updated
18
+
19
+ ## 0.0.9
20
+
21
+ ### Patch Changes
22
+
23
+ - 7e8b7d1: removes an abstract method from POMWright/BasePage which should have been removed previously
24
+
3
25
  ## 0.0.8
4
26
 
5
27
  ### Patch Changes
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # POMWright
2
2
 
3
- ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/DyHex/POMWright/main.yaml?label=CI%20on%20main) ![NPM Version](https://img.shields.io/npm/v/pomwright?link=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2Fpomwright) ![NPM Downloads](https://img.shields.io/npm/dt/pomwright) ![GitHub License](https://img.shields.io/github/license/DyHex/POMWright) ![NPM dev or peer Dependency Version](https://img.shields.io/npm/dependency-version/pomwright/peer/%40playwright%2Ftest)
4
-
3
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/DyHex/POMWright/main.yaml?label=CI%20on%20main) [![NPM Version](https://img.shields.io/npm/v/pomwright)](https://www.npmjs.com/package/pomwright) ![NPM Downloads](https://img.shields.io/npm/dt/pomwright) ![GitHub License](https://img.shields.io/github/license/DyHex/POMWright) [![NPM dev or peer Dependency Version](https://img.shields.io/npm/dependency-version/pomwright/peer/%40playwright%2Ftest)](https://www.npmjs.com/package/playwright) [![Static Badge](https://img.shields.io/badge/created%40-ICE-ffcd00)](https://www.ice.no/)
5
4
 
6
5
  POMWright is a TypeScript-based framework that implements the Page Object Model Design Pattern, designed specifically to augment Playwright's testing capabilities.
7
6
 
@@ -9,39 +8,105 @@ POMWright provides a way of abstracting the implementation details of a web page
9
8
 
10
9
  ## Features
11
10
 
12
- **Easy Creation of Page Object Classes:**
13
- Extend a class with POMwright to create a Page Object Class (POC).
11
+ ### Easy Creation of Page Object Classes
12
+
13
+ Simply extend a class with BasePage to create a Page Object Class (POC).
14
+
15
+ ### Support for Multiple Domains/BaseURLs
16
+
17
+ Define different base URLs by extending an abstract class with BasePage and have your POCs extend it.
18
+
19
+ ### Custom Playwright Fixture Integration
20
+
21
+ Seamlessly integrate custom Playwright Fixtures with your POMWright POCs.
22
+
23
+ ### LocatorSchema Interface
14
24
 
15
- **Support for Multiple Domains/BaseURLs:**
16
- Extend an abstract class with POMWright with a given BaseUrl, then create POCs for that BaseUrl by extending the abstract class.
25
+ Define comprehensive locators for each POC and share common locators between them.
17
26
 
18
- **Custom Playwright Fixture Integration:** Create custom Playwright Fixtures from your POMWright POCs by extending test as POMWrightTestFixture.
27
+ ### Advanced Locator Management
19
28
 
20
- **LocatorSchema Interface:** Offers a way to define and structure comprehensive locators per POC and share common locators between them.
29
+ Efficiently manage and chain locators through LocatorSchemaPaths.
21
30
 
22
- **Advanced Locator Management:** Enables retrieval and automatic chaining of locators using LocatorSchemaPath.
31
+ ### Dynamic Locator Schema Updates
23
32
 
24
- **LocatorSchema Update/Updatess:** Allows updating single locators aswell as each locator a chained locator consist of, dynamically throughout a test.
33
+ Modify single or multiple locators within a chained locator dynamically during tests.
25
34
 
26
- **Deep Copy of LocatorSchemas:** Ensures original LocatorSchemas are reusable in tests.
35
+ ### Deep Copy of LocatorSchemas
27
36
 
28
- **Custom HTML Logger:** Provides detailed logs for nested locators, aiding in debugging and integration with Playwright's HTML report.
37
+ Ensure that original LocatorSchemas remain immutable and reusable across tests.
29
38
 
30
- **SessionStorage Handling:** Includes methods for managing sessionStorage, complementing Playwright's capabilities.
39
+ ### Custom HTML Logger
40
+
41
+ Gain insights with detailed logs for nested locators, integrated with Playwright's HTML report. Or use the Log fixture throughout your own POCs and tests to easily attach them to the HTML report based on log levels.
42
+
43
+ ### SessionStorage Handling
44
+
45
+ Enhance your tests with advanced sessionStorage handling capabilities.
31
46
 
32
47
  ## Installation
33
48
 
49
+ Ensure you have Node.js installed, then run:
50
+
34
51
  ```bash
35
52
  npm install pomwright --save-dev
36
53
  ```
37
54
 
55
+ or
56
+
57
+ ```bash
58
+ pnpm i -D pomwright
59
+ ```
60
+
61
+ ## Playwright Example Project
62
+
63
+ Explore POMWright in action by diving into the example project located in the "example" folder. Follow these steps to get started:
64
+
65
+ ### Install
66
+
67
+ Navigate to the "example" folder and install the necessary dependencies:
68
+
69
+ ```bash
70
+ pnpm install
71
+ ```
72
+
73
+ ### Playwright browsers
74
+
75
+ Install or update Playwright browsers:
76
+
77
+ ```bash
78
+ pnpm playwright install --with-deps
79
+ ```
80
+
81
+ ### Run tests
82
+
83
+ Execute tests across chromium, firefox, and webkit:
84
+
85
+ ```bash
86
+ pnpm playwright test
87
+ ```
88
+
89
+ ### Parallelism
90
+
91
+ Control parallel test execution. By default, up to 4 tests run in parallel. Modify this setting as needed:
92
+
93
+ ```bash
94
+ pnpm playwright test --workers 2 # Set the number of parallel workers
95
+ ```
96
+
97
+ ### Reports
98
+
99
+ After the tests complete, a Playwright HTML report is available in ./example/playwright-report. Open the index.html file in your browser to view the results.
100
+
38
101
  ## Usage
39
102
 
40
- **Simple example of creating a Page Object Class:**
103
+ Dive into using POMWright with these examples:
104
+
105
+ ### Create a Page Object Class (POC)
41
106
 
42
107
  ```TS
43
108
  import { Page, TestInfo } from "@playwright/test";
44
- import { POMWright, POMWrightLogger } from "pomwright";
109
+ import { BasePage, PlaywrightReportLogger, GetByMethod } from "pomwright";
45
110
 
46
111
  type LocatorSchemaPath =
47
112
  | "content"
@@ -49,8 +114,8 @@ type LocatorSchemaPath =
49
114
  | "content.region.details"
50
115
  | "content.region.details.button.edit";
51
116
 
52
- export default class Profile extends POMWright<LocatorSchemaPath> {
53
- constructor(page: Page, testInfo: TestInfo, pwrl: POMWrightLogger) {
117
+ export default class Profile extends BasePage<LocatorSchemaPath> {
118
+ constructor(page: Page, testInfo: TestInfo, pwrl: PlaywrightReportLogger) {
54
119
  super(page, testInfo, "https://someDomain.com", "/profile", Profile.name, pwrl);
55
120
  }
56
121
 
@@ -64,7 +129,7 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
64
129
  role: "heading",
65
130
  roleOptions: {
66
131
  name: "Your Profile"
67
- }
132
+ },
68
133
  locatorMethod: GetByMethod.role
69
134
  });
70
135
 
@@ -72,7 +137,7 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
72
137
  role: "region",
73
138
  roleOptions: {
74
139
  name: "Profile Details"
75
- }
140
+ },
76
141
  locatorMethod: GetByMethod.role
77
142
  });
78
143
 
@@ -80,7 +145,7 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
80
145
  role: "button",
81
146
  roleOptions: {
82
147
  name: "Edit"
83
- }
148
+ },
84
149
  locatorMethod: GetByMethod.role
85
150
  });
86
151
  }
@@ -89,10 +154,10 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
89
154
  }
90
155
  ```
91
156
 
92
- **Creating a Custom Playwright Fixture for the Profile POC:**
157
+ ### Creating a Custom Playwright Fixture
93
158
 
94
159
  ```TS
95
- import { POMWrightTestFixture as base } from "pomwright";
160
+ import { test as base } from "pomwright";
96
161
  import Profile from "...";
97
162
 
98
163
  type fixtures = {
@@ -107,7 +172,9 @@ export const test = base.extend<fixtures>({
107
172
  });
108
173
  ```
109
174
 
110
- **Using the fixture in a Playwright tests:**
175
+ ### Using the fixture in a Playwright tests
176
+
177
+ #### Click edit button with a single locator
111
178
 
112
179
  ```TS
113
180
  import { test } from ".../fixtures";
@@ -127,6 +194,8 @@ test("click edit button with a single locator", async ({ profile }) => {
127
194
  });
128
195
  ```
129
196
 
197
+ #### Click edit button with a nested locator
198
+
130
199
  ```TS
131
200
  import { test } from ".../fixtures";
132
201
 
@@ -148,6 +217,8 @@ test("click edit button with a nested locator", async ({ profile }) => {
148
217
  });
149
218
  ```
150
219
 
220
+ #### Specify index for nested locator(s)
221
+
151
222
  ```TS
152
223
  import { test } from ".../fixtures";
153
224
 
@@ -171,6 +242,8 @@ test("specify index for nested locator(s)", async ({ profile }) => {
171
242
  });
172
243
  ```
173
244
 
245
+ #### Update a locator before use
246
+
174
247
  ```TS
175
248
  import { test } from ".../fixtures";
176
249
 
@@ -194,6 +267,8 @@ test("update a locator before use", async ({ profile }) => {
194
267
  });
195
268
  ```
196
269
 
270
+ #### Update a nested locator before use
271
+
197
272
  ```TS
198
273
  import { test } from ".../fixtures";
199
274
 
@@ -222,6 +297,8 @@ test("update a nested locator before use", async ({ profile }) => {
222
297
  });
223
298
  ```
224
299
 
300
+ #### Make multiple versions of a locator
301
+
225
302
  ```TS
226
303
  import { test } from ".../fixtures";
227
304
 
@@ -247,3 +324,15 @@ test("make multiple versions of a locator", async ({ profile }) => {
247
324
 
248
325
  });
249
326
  ```
327
+
328
+ ## Troubleshooting and Support
329
+
330
+ If you encounter any issues or have questions, please check our issues page or reach out to us directly.
331
+
332
+ ## Contributing
333
+
334
+ Pull Requests are welcome!
335
+
336
+ ## License
337
+
338
+ POMWright is open-source software licensed under the Apache-2.0 license
package/biome.json CHANGED
@@ -1,15 +1,20 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/1.2.2/schema.json",
3
- "organizeImports": {
4
- "enabled": true
5
- },
6
- "linter": {
7
- "enabled": true,
8
- "rules": {
9
- "recommended": true
10
- }
11
- },
12
- "formatter": {
13
- "formatWithErrors": true
14
- }
15
- }
2
+ "$schema": "https://biomejs.dev/schemas/1.2.2/schema.json",
3
+ "organizeImports": {
4
+ "enabled": true
5
+ },
6
+ "linter": {
7
+ "enabled": true,
8
+ "rules": {
9
+ "recommended": true
10
+ }
11
+ },
12
+ "formatter": {
13
+ "enabled": true,
14
+ "formatWithErrors": true,
15
+ "indentStyle": "tab",
16
+ "indentWidth": 2,
17
+ "lineWidth": 120,
18
+ "ignore": []
19
+ }
20
+ }