pomwright 0.0.9 → 1.0.1
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 +53 -0
- package/README.md +111 -21
- package/biome.json +28 -14
- package/dist/index.d.mts +144 -147
- package/dist/index.d.ts +144 -147
- package/dist/index.js +271 -320
- package/dist/index.mjs +267 -318
- package/index.ts +6 -6
- package/pack-test.sh +47 -0
- package/package.json +9 -5
- package/vitest.config.ts +9 -0
- package/.vscode/extensions.json +0 -5
- package/.vscode/settings.json +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# pomwright
|
|
2
2
|
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#23](https://github.com/DyHex/POMWright/pull/23) [`0cfc19f`](https://github.com/DyHex/POMWright/commit/0cfc19f057575365853f9df41bbd661bf45172e2) Thanks [@DyHex](https://github.com/DyHex)! - # Continuous testing & bug fixes
|
|
8
|
+
|
|
9
|
+
## Bug fixes
|
|
10
|
+
|
|
11
|
+
- getLocatorBase.applyUpdate() now correctly updates the LocatorSchemaWithMethod and maintains a circular ref. for the entry representing itself in schemasMap
|
|
12
|
+
- getLocatorBase.applyUpdates() now correctly updates the LocatorSchemaWithMethod and maintains a circular ref. for the entry representing itself in schemasMap while updating other LocatorSchema in SchemasMap directly.
|
|
13
|
+
- getLocatorBase.deepMerge() now correctly validates valid nested properties of LocatorSchema
|
|
14
|
+
|
|
15
|
+
## Continuous testing
|
|
16
|
+
|
|
17
|
+
- Build workflow now runs unit tests (vitest)
|
|
18
|
+
- New shell script enabling testing new packages before release
|
|
19
|
+
- New test workflow for POMWright integration tests (Playwright/test)
|
|
20
|
+
- 52 new unit tests, more to come..
|
|
21
|
+
- 4 new integration tests, more to come..
|
|
22
|
+
|
|
23
|
+
New release has also been tested with a seperate Playwright/test project leveraging POMWright (~100 E2E tests)
|
|
24
|
+
|
|
25
|
+
## Playwright/test compatibility
|
|
26
|
+
|
|
27
|
+
Tested with the following Playwright/test versions:
|
|
28
|
+
|
|
29
|
+
- 1.43.1
|
|
30
|
+
- 1.43.0
|
|
31
|
+
- 1.42.1
|
|
32
|
+
- 1.42.0 (not recommended)
|
|
33
|
+
- 1.41.2
|
|
34
|
+
- 1.41.1
|
|
35
|
+
- 1.41.0
|
|
36
|
+
- 1.40.1
|
|
37
|
+
- 1.40.0
|
|
38
|
+
- 1.39.0
|
|
39
|
+
|
|
40
|
+
## 1.0.0
|
|
41
|
+
|
|
42
|
+
### Major Changes
|
|
43
|
+
|
|
44
|
+
- 130784f: BREAKING: The following index.ts exports have been renamed:
|
|
45
|
+
|
|
46
|
+
- "POMWright" changed to "BasePage"
|
|
47
|
+
- "POMWrightTestFixture" changed to "test"
|
|
48
|
+
- "POMWrightLogger" changed to "PlaywrightReportLogger"
|
|
49
|
+
- "POMWrightGetLocatorBase" changed to "GetLocatorBase"
|
|
50
|
+
- "POMWrightApi" changed to "BaseApi"
|
|
51
|
+
|
|
52
|
+
Documentation updated
|
|
53
|
+
|
|
54
|
+
README updated
|
|
55
|
+
|
|
3
56
|
## 0.0.9
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -8,39 +8,105 @@ POMWright provides a way of abstracting the implementation details of a web page
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
Extend a class with POMwright to create a Page Object Class (POC).
|
|
11
|
+
### Easy Creation of Page Object Classes
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
Extend an abstract class with POMWright with a given BaseUrl, then create POCs for that BaseUrl by extending the abstract class.
|
|
13
|
+
Simply extend a class with BasePage to create a Page Object Class (POC).
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
### Support for Multiple Domains/BaseURLs
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
Define different base URLs by extending an abstract class with BasePage per domain and have your POCs for each domain extend the abstract classes.
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
### Custom Playwright Fixture Integration
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
Seamlessly integrate custom Playwright Fixtures with your POMWright POCs.
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
### LocatorSchema Interface
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
Define comprehensive locators for each POC and share common locators between them.
|
|
28
26
|
|
|
29
|
-
|
|
27
|
+
### Advanced Locator Management
|
|
28
|
+
|
|
29
|
+
Efficiently manage and chain locators through LocatorSchemaPaths.
|
|
30
|
+
|
|
31
|
+
### Dynamic Locator Schema Updates
|
|
32
|
+
|
|
33
|
+
Modify single or multiple locators within a chained locator dynamically during tests.
|
|
34
|
+
|
|
35
|
+
### Deep Copy of LocatorSchemas
|
|
36
|
+
|
|
37
|
+
Ensure that original LocatorSchemas remain immutable and reusable across tests.
|
|
38
|
+
|
|
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.
|
|
30
46
|
|
|
31
47
|
## Installation
|
|
32
48
|
|
|
49
|
+
Ensure you have Node.js installed, then run:
|
|
50
|
+
|
|
33
51
|
```bash
|
|
34
52
|
npm install pomwright --save-dev
|
|
35
53
|
```
|
|
36
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
|
+
|
|
37
101
|
## Usage
|
|
38
102
|
|
|
39
|
-
|
|
103
|
+
Dive into using POMWright with these examples:
|
|
104
|
+
|
|
105
|
+
### Create a Page Object Class (POC)
|
|
40
106
|
|
|
41
107
|
```TS
|
|
42
108
|
import { Page, TestInfo } from "@playwright/test";
|
|
43
|
-
import {
|
|
109
|
+
import { BasePage, PlaywrightReportLogger, GetByMethod } from "pomwright";
|
|
44
110
|
|
|
45
111
|
type LocatorSchemaPath =
|
|
46
112
|
| "content"
|
|
@@ -48,8 +114,8 @@ type LocatorSchemaPath =
|
|
|
48
114
|
| "content.region.details"
|
|
49
115
|
| "content.region.details.button.edit";
|
|
50
116
|
|
|
51
|
-
export default class Profile extends
|
|
52
|
-
constructor(page: Page, testInfo: TestInfo, pwrl:
|
|
117
|
+
export default class Profile extends BasePage<LocatorSchemaPath> {
|
|
118
|
+
constructor(page: Page, testInfo: TestInfo, pwrl: PlaywrightReportLogger) {
|
|
53
119
|
super(page, testInfo, "https://someDomain.com", "/profile", Profile.name, pwrl);
|
|
54
120
|
}
|
|
55
121
|
|
|
@@ -63,7 +129,7 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
|
|
|
63
129
|
role: "heading",
|
|
64
130
|
roleOptions: {
|
|
65
131
|
name: "Your Profile"
|
|
66
|
-
}
|
|
132
|
+
},
|
|
67
133
|
locatorMethod: GetByMethod.role
|
|
68
134
|
});
|
|
69
135
|
|
|
@@ -71,7 +137,7 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
|
|
|
71
137
|
role: "region",
|
|
72
138
|
roleOptions: {
|
|
73
139
|
name: "Profile Details"
|
|
74
|
-
}
|
|
140
|
+
},
|
|
75
141
|
locatorMethod: GetByMethod.role
|
|
76
142
|
});
|
|
77
143
|
|
|
@@ -79,7 +145,7 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
|
|
|
79
145
|
role: "button",
|
|
80
146
|
roleOptions: {
|
|
81
147
|
name: "Edit"
|
|
82
|
-
}
|
|
148
|
+
},
|
|
83
149
|
locatorMethod: GetByMethod.role
|
|
84
150
|
});
|
|
85
151
|
}
|
|
@@ -88,10 +154,10 @@ export default class Profile extends POMWright<LocatorSchemaPath> {
|
|
|
88
154
|
}
|
|
89
155
|
```
|
|
90
156
|
|
|
91
|
-
|
|
157
|
+
### Creating a Custom Playwright Fixture
|
|
92
158
|
|
|
93
159
|
```TS
|
|
94
|
-
import {
|
|
160
|
+
import { test as base } from "pomwright";
|
|
95
161
|
import Profile from "...";
|
|
96
162
|
|
|
97
163
|
type fixtures = {
|
|
@@ -106,7 +172,9 @@ export const test = base.extend<fixtures>({
|
|
|
106
172
|
});
|
|
107
173
|
```
|
|
108
174
|
|
|
109
|
-
|
|
175
|
+
### Using the fixture in a Playwright tests
|
|
176
|
+
|
|
177
|
+
#### Click edit button with a single locator
|
|
110
178
|
|
|
111
179
|
```TS
|
|
112
180
|
import { test } from ".../fixtures";
|
|
@@ -126,6 +194,8 @@ test("click edit button with a single locator", async ({ profile }) => {
|
|
|
126
194
|
});
|
|
127
195
|
```
|
|
128
196
|
|
|
197
|
+
#### Click edit button with a nested locator
|
|
198
|
+
|
|
129
199
|
```TS
|
|
130
200
|
import { test } from ".../fixtures";
|
|
131
201
|
|
|
@@ -147,6 +217,8 @@ test("click edit button with a nested locator", async ({ profile }) => {
|
|
|
147
217
|
});
|
|
148
218
|
```
|
|
149
219
|
|
|
220
|
+
#### Specify index for nested locator(s)
|
|
221
|
+
|
|
150
222
|
```TS
|
|
151
223
|
import { test } from ".../fixtures";
|
|
152
224
|
|
|
@@ -170,6 +242,8 @@ test("specify index for nested locator(s)", async ({ profile }) => {
|
|
|
170
242
|
});
|
|
171
243
|
```
|
|
172
244
|
|
|
245
|
+
#### Update a locator before use
|
|
246
|
+
|
|
173
247
|
```TS
|
|
174
248
|
import { test } from ".../fixtures";
|
|
175
249
|
|
|
@@ -193,6 +267,8 @@ test("update a locator before use", async ({ profile }) => {
|
|
|
193
267
|
});
|
|
194
268
|
```
|
|
195
269
|
|
|
270
|
+
#### Update a nested locator before use
|
|
271
|
+
|
|
196
272
|
```TS
|
|
197
273
|
import { test } from ".../fixtures";
|
|
198
274
|
|
|
@@ -221,6 +297,8 @@ test("update a nested locator before use", async ({ profile }) => {
|
|
|
221
297
|
});
|
|
222
298
|
```
|
|
223
299
|
|
|
300
|
+
#### Make multiple versions of a locator
|
|
301
|
+
|
|
224
302
|
```TS
|
|
225
303
|
import { test } from ".../fixtures";
|
|
226
304
|
|
|
@@ -246,3 +324,15 @@ test("make multiple versions of a locator", async ({ profile }) => {
|
|
|
246
324
|
|
|
247
325
|
});
|
|
248
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,29 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
"files": {
|
|
21
|
+
"ignore": [
|
|
22
|
+
"dist/**",
|
|
23
|
+
"node_modules/**",
|
|
24
|
+
"example/node_modules/**",
|
|
25
|
+
"example/playwright-report/**",
|
|
26
|
+
"example/test-results/**"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|