create-playwright-pom-start 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/README.md +33 -17
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -26,13 +26,15 @@ npm init playwright-pom-start
26
26
  7. 🔗 [Repository & docs](#repository--docs)
27
27
  8. 👤 [Author & license](#author--license)
28
28
 
29
- ## Why use this
29
+ ## 💡 Why Playwright POM?
30
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.
31
+ - **Zero setup time:** One command creates your entire framework structure, folders, base classes, config files. No more copy-pasting from old projects.
32
+ - **Smart and flexible:** Installs Playwright if needed, lets you pick JavaScript or TypeScript, and scaffolds page classes on the spot or later. Yes, batteries included.
33
+ - **Works with existing projects:** Already have a Playwright repo? Add new page objects anytime without touching your current setup.
32
34
 
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.
35
+ > **Note:** All generated code uses ES module syntax (import/export). No require(), no CommonJS.
34
36
 
35
- ## Getting started
37
+ ## 🚀 Getting started
36
38
 
37
39
  **Requirements:** Node.js **v18** or later.
38
40
 
@@ -44,15 +46,10 @@ Run in an empty folder or from any directory to scaffold into a named subfolder:
44
46
  npm init playwright-pom-start
45
47
  ```
46
48
 
47
- or into a subfolder:
48
49
 
49
- ```bash
50
- npx playwright-pom my-project
51
- ```
52
-
53
- You'll be prompted for:
50
+ You'll be asked for:
54
51
 
55
- 1. **Language** — JavaScript or TypeScript (arrow keys + Enter). Default is JS. Skipped if Playwright is already detected in the folder.
52
+ 1. **Language** — JavaScript or TypeScript (arrow keys + Enter). Default is JS. Skipped if Playwright and language are already detected in the project.
56
53
  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
54
  3. **Playwright** — installed automatically if missing.
58
55
 
@@ -66,14 +63,14 @@ npx playwright-pom add pages
66
63
 
67
64
  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
65
 
69
- ## How it works
66
+ ## ⚙️ How it works
70
67
 
71
68
  - If Playwright is **already installed** in the folder, the CLI detects JS or TS and skips the language question.
72
69
  - Templates are copied, folders and placeholder files are created.
73
70
  - If Playwright isn't installed yet, the CLI runs `npm init playwright@latest -- --quiet --lang=js` or `--lang=ts` to match the chosen language.
74
71
  - 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`.
75
72
 
76
- ## Generated structure
73
+ ## 🗂️ Generated structure
77
74
 
78
75
  ```
79
76
  <project>/
@@ -91,18 +88,37 @@ The CLI detects your project language from existing config files or the `pages`
91
88
  └── .gitignore # includes states
92
89
  ```
93
90
 
91
+ All page classes extend **BasePage** and pass the Playwright `page` to the constructor. Example (JavaScript):
92
+
93
+ ```js
94
+ import BasePage from "./BasePage.js";
95
+
96
+ class DashboardPage extends BasePage {
97
+ constructor(page) {
98
+ super(page);
99
+ }
100
+ }
101
+
102
+ export default DashboardPage;
103
+ ```
104
+
105
+ For TypeScript, the same pattern is used with `import type { Page } from "@playwright/test"` and `constructor(page: Page)`.
106
+
94
107
  - **BasePage** — Shared class with the Playwright `page`; other pages extend it.
95
108
  - **utils/logger** — Placeholder for your logger.
96
109
  - **utils/auth** — For auth-related helpers.
110
+ - **fixtures/** — Add your fixtures in this folder.
111
+ - **constants/** — Add your constants files here.
112
+ - **states/** — For storage state files, already added into .gitignore file
97
113
  - **global-setup** / **global-teardown** — Default async functions; wire them in `playwright.config.*` if you use them.
98
114
 
99
- ## Page naming
115
+ ## 🏷️ Page naming
100
116
 
101
117
  - Letters only (no numbers, `.js`/`.ts`, or symbols).
102
118
  - Converted to PascalCase + `Page` (e.g. `checkout` → `CheckoutPage`, `userProfile` → `UserProfilePage`).
103
119
  - Invalid tokens and existing files are skipped (reported in the console).
104
120
 
105
- ## Examples
121
+ ## 🖼️ Examples
106
122
 
107
123
  **JavaScript based output project structure**
108
124
 
@@ -120,12 +136,12 @@ The CLI detects your project language from existing config files or the `pages`
120
136
 
121
137
  ![TypeScript based output created page example](https://raw.githubusercontent.com/GabrielDali/pom-pw-js/main/assets/04.png)
122
138
 
123
- ## Repository & docs
139
+ ## 🔗 Repository & docs
124
140
 
125
141
  - **GitHub:** [github.com/GabrielDali/pom-pw-js](https://github.com/GabrielDali/pom-pw-js)
126
142
  - **Main package (playwright-pom):** [npmjs.com/package/playwright-pom](https://www.npmjs.com/package/playwright-pom)
127
143
 
128
- ## Author & license
144
+ ## 👤 Author & license
129
145
 
130
146
  **Author:** [Gabriel Dali](https://www.linkedin.com/in/gabriel-dali-qa/)
131
147
  **License:** MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-playwright-pom-start",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Scaffold a Playwright POM project (run via npm init playwright-pom-start)",
5
5
  "keywords": [
6
6
  "playwright",