create-playwright-pom-start 1.0.7 → 1.0.8
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/README.md +50 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,50 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>Playwright POM framework</h1>
|
|
3
|
+
<hr />
|
|
4
|
+
<p><small>An open source CLI-tool for quick start with Page Object Model project and Playwright framework</small></p>
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://www.npmjs.com/package/create-playwright-pom-start"><img src="https://img.shields.io/npm/v/create-playwright-pom-start?color=0062cc" alt="npm version" /></a>
|
|
7
|
+
<a href="https://github.com/GabrielDali/pom-pw-js/actions"><img src="https://img.shields.io/github/actions/workflow/status/GabrielDali/pom-pw-js/publish.yml?branch=main&label=CI&logo=github" alt="CI" /></a>
|
|
8
|
+
<a href="https://www.npmjs.com/package/create-playwright-pom-start"><img src="https://img.shields.io/npm/l/create-playwright-pom-start?color=006e75" alt="MIT License" /></a>
|
|
9
|
+
</p>
|
|
10
|
+
</div>
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
13
|
npm init playwright-pom-start
|
|
11
14
|
```
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## Table of Contents
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
1. 💡 [Why use this](#why-use-this)
|
|
19
|
+
2. 🚀 [Getting started](#getting-started)
|
|
20
|
+
- 2.1 [New project](#new-project)
|
|
21
|
+
- 2.2 [Add pages to an existing project](#add-pages-to-an-existing-project)
|
|
22
|
+
3. ⚙️ [How it works](#how-it-works)
|
|
23
|
+
4. 🗂️ [Generated structure](#generated-structure)
|
|
24
|
+
5. 🏷️ [Page naming](#page-naming)
|
|
25
|
+
6. 🖼️ [Examples](#examples)
|
|
26
|
+
7. 🔗 [Repository & docs](#repository--docs)
|
|
27
|
+
8. 👤 [Author & license](#author--license)
|
|
18
28
|
|
|
29
|
+
## Why use this
|
|
19
30
|
|
|
31
|
+
Playwright gives you a powerful testing API but no folder structure. As your test suite grows, tests start reaching directly into selectors and actions, which means one UI change can break many tests instead of one. Page Object Model fixes that by keeping each page's interactions in one place. Your tests only call methods, not raw selectors.
|
|
20
32
|
|
|
21
|
-
|
|
33
|
+
Setting up POM manually means writing the same base class, the same folder layout, and the same boilerplate on every project. This CLI does it in one command: it creates the structure, scaffolds your first pages, and installs Playwright if it isn't there yet.
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
2. **Page names** — optional; space-separated, or Enter to skip. Names are normalized to PascalCase + `Page` (e.g. `dashboard` → `DashboardPage`).
|
|
25
|
-
3. **Playwright** — installed automatically if missing.
|
|
35
|
+
## Getting started
|
|
26
36
|
|
|
27
37
|
**Requirements:** Node.js **v18** or later.
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
### New project
|
|
40
|
+
|
|
41
|
+
Run in an empty folder or from any directory to scaffold into a named subfolder:
|
|
30
42
|
|
|
31
43
|
```bash
|
|
32
|
-
npm
|
|
33
|
-
npx playwright-pom
|
|
44
|
+
npm init playwright-pom-start
|
|
34
45
|
```
|
|
35
46
|
|
|
36
|
-
|
|
47
|
+
or into a subfolder:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx playwright-pom my-project
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You'll be prompted for:
|
|
54
|
+
|
|
55
|
+
1. **Language** — JavaScript or TypeScript (arrow keys + Enter). Default is JS. Skipped if Playwright is already detected in the folder.
|
|
56
|
+
2. **Page names** — optional; type names separated by spaces, or press Enter to skip. Names are normalized to PascalCase + `Page` (e.g. `dashboard` → `DashboardPage`).
|
|
57
|
+
3. **Playwright** — installed automatically if missing.
|
|
58
|
+
|
|
59
|
+
### Add pages to an existing project
|
|
60
|
+
|
|
61
|
+
Run from the root of your project, where the `pages` folder lives:
|
|
37
62
|
|
|
38
|
-
To **add more pages** to an existing project, run from the project root:
|
|
39
63
|
```bash
|
|
40
64
|
npx playwright-pom add pages
|
|
41
65
|
```
|
|
42
66
|
|
|
43
|
-
|
|
67
|
+
The CLI detects your project language from existing config files or the `pages` folder contents. If it can't detect a language, it asks. If no `pages` folder exists yet, it creates one and copies `BasePage` before prompting for page names.
|
|
68
|
+
|
|
69
|
+
## How it works
|
|
44
70
|
|
|
45
71
|
- If Playwright is **already installed** in the folder, the CLI detects JS or TS and skips the language question.
|
|
46
72
|
- Templates are copied, folders and placeholder files are created.
|
|
47
|
-
- If Playwright isn
|
|
73
|
+
- If Playwright isn't installed yet, the CLI runs `npm init playwright@latest -- --quiet --lang=js` or `--lang=ts` to match the chosen language.
|
|
48
74
|
- If the folder already has a scaffold (e.g. `pages/BasePage.js` or `pages/BasePage.ts`), the CLI prints **"Project already set up. Skipping."** and may run `npm install`.
|
|
49
75
|
|
|
50
76
|
## Generated structure
|
|
@@ -76,6 +102,7 @@ npx playwright-pom add pages
|
|
|
76
102
|
- Converted to PascalCase + `Page` (e.g. `checkout` → `CheckoutPage`, `userProfile` → `UserProfilePage`).
|
|
77
103
|
- Invalid tokens and existing files are skipped (reported in the console).
|
|
78
104
|
|
|
105
|
+
## Examples
|
|
79
106
|
|
|
80
107
|
**JavaScript based output project structure**
|
|
81
108
|
|
|
@@ -100,5 +127,5 @@ npx playwright-pom add pages
|
|
|
100
127
|
|
|
101
128
|
## Author & license
|
|
102
129
|
|
|
103
|
-
**Author:** [Gabriel Dali](https://www.linkedin.com/in/gabriel-dali-qa/)
|
|
130
|
+
**Author:** [Gabriel Dali](https://www.linkedin.com/in/gabriel-dali-qa/)
|
|
104
131
|
**License:** MIT
|