simple-playwright-framework 0.0.13 → 0.0.15
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 +183 -0
- package/package.json +1 -1
- package/scripts/init-demo-project.js +5 -2
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# simple-playwright-framework
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
A lightweight and modular automation framework built on top of
|
|
12
|
+
**Microsoft Playwright** to help teams quickly bootstrap scalable UI and
|
|
13
|
+
API test automation projects.
|
|
14
|
+
|
|
15
|
+
The framework focuses on simplicity, maintainability, and developer
|
|
16
|
+
ergonomics while following modern test automation best practices.
|
|
17
|
+
|
|
18
|
+
Repository: https://github.com/Udayakumarg/simpleplaywrightframework
|
|
19
|
+
|
|
20
|
+
------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- Playwright-powered end‑to‑end browser automation
|
|
25
|
+
- Clean and scalable project structure
|
|
26
|
+
- Environment-aware configuration
|
|
27
|
+
- Reusable authentication sessions
|
|
28
|
+
- UI and API testing support
|
|
29
|
+
- File upload and download helpers
|
|
30
|
+
- CLI project scaffolding
|
|
31
|
+
- CI/CD ready architecture
|
|
32
|
+
- Easy integration with reporting tools such as Allure and TestRail
|
|
33
|
+
|
|
34
|
+
------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
### 1. Install Playwright
|
|
39
|
+
|
|
40
|
+
``` bash
|
|
41
|
+
npm install --save-dev @playwright/test playwright
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Install the framework
|
|
45
|
+
|
|
46
|
+
``` bash
|
|
47
|
+
npm install simple-playwright-framework
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
## Create a Demo Project
|
|
53
|
+
|
|
54
|
+
Use the CLI to generate a ready‑to‑run project:
|
|
55
|
+
|
|
56
|
+
``` bash
|
|
57
|
+
npx init-demo-project
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This command scaffolds a demo project with the recommended structure.
|
|
61
|
+
|
|
62
|
+
------------------------------------------------------------------------
|
|
63
|
+
|
|
64
|
+
## Run Tests
|
|
65
|
+
|
|
66
|
+
Navigate into the generated project and run:
|
|
67
|
+
|
|
68
|
+
``` bash
|
|
69
|
+
cd demo-project
|
|
70
|
+
npx playwright test
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Run tests with the Playwright UI runner:
|
|
74
|
+
|
|
75
|
+
``` bash
|
|
76
|
+
npx playwright test --ui
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
## Example Test
|
|
82
|
+
|
|
83
|
+
``` ts
|
|
84
|
+
import { test, expect } from '@playwright/test';
|
|
85
|
+
|
|
86
|
+
test('homepage loads', async ({ page }) => {
|
|
87
|
+
await page.goto('https://example.com');
|
|
88
|
+
await expect(page).toHaveTitle(/Example/);
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
------------------------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
## Project Structure
|
|
95
|
+
|
|
96
|
+
Example project generated by the framework:
|
|
97
|
+
|
|
98
|
+
demo-project
|
|
99
|
+
│
|
|
100
|
+
├── tests
|
|
101
|
+
│ └── example.spec.ts
|
|
102
|
+
│
|
|
103
|
+
├── pages
|
|
104
|
+
│ └── login.page.ts
|
|
105
|
+
│
|
|
106
|
+
├── utils
|
|
107
|
+
│ └── apiClient.ts
|
|
108
|
+
│
|
|
109
|
+
├── config
|
|
110
|
+
│ └── environments.ts
|
|
111
|
+
│
|
|
112
|
+
├── auth
|
|
113
|
+
│ └── storageState.json
|
|
114
|
+
│
|
|
115
|
+
└── playwright.config.ts
|
|
116
|
+
|
|
117
|
+
------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
## Environment Configuration
|
|
120
|
+
|
|
121
|
+
Multiple environments can be configured easily.
|
|
122
|
+
|
|
123
|
+
Example:
|
|
124
|
+
|
|
125
|
+
``` ts
|
|
126
|
+
export const environments = {
|
|
127
|
+
dev: {
|
|
128
|
+
baseUrl: "https://dev.example.com"
|
|
129
|
+
},
|
|
130
|
+
qa: {
|
|
131
|
+
baseUrl: "https://qa.example.com"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
This allows running tests across different deployment environments
|
|
137
|
+
without changing test logic.
|
|
138
|
+
|
|
139
|
+
------------------------------------------------------------------------
|
|
140
|
+
|
|
141
|
+
## Reporting
|
|
142
|
+
|
|
143
|
+
The framework works seamlessly with:
|
|
144
|
+
|
|
145
|
+
- Playwright HTML reports
|
|
146
|
+
- Allure reports
|
|
147
|
+
- TestRail integrations
|
|
148
|
+
|
|
149
|
+
Generate the Playwright report:
|
|
150
|
+
|
|
151
|
+
``` bash
|
|
152
|
+
npx playwright show-report
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
------------------------------------------------------------------------
|
|
156
|
+
|
|
157
|
+
## Contributing
|
|
158
|
+
|
|
159
|
+
Contributions are welcome.
|
|
160
|
+
|
|
161
|
+
If you would like to contribute:
|
|
162
|
+
|
|
163
|
+
1. Fork the repository
|
|
164
|
+
2. Create a feature branch
|
|
165
|
+
3. Commit your changes
|
|
166
|
+
4. Submit a pull request
|
|
167
|
+
|
|
168
|
+
Please ensure that code changes include appropriate tests and follow
|
|
169
|
+
existing coding conventions.
|
|
170
|
+
|
|
171
|
+
------------------------------------------------------------------------
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT License
|
|
176
|
+
|
|
177
|
+
------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
## Author
|
|
180
|
+
|
|
181
|
+
Developed by Udayakumar
|
|
182
|
+
|
|
183
|
+
GitHub: https://github.com/Udayakumarg
|
package/package.json
CHANGED
|
@@ -68,12 +68,15 @@ export default defineConfig({
|
|
|
68
68
|
testDir: './tests',
|
|
69
69
|
reporter: [['html']],
|
|
70
70
|
use: {
|
|
71
|
-
//
|
|
72
|
-
env: process.env.TEST_ENV || "prod",
|
|
71
|
+
// keep Playwright's own options here
|
|
73
72
|
},
|
|
74
73
|
});
|
|
74
|
+
|
|
75
|
+
// ✅ Default environment set to "prod"
|
|
76
|
+
process.env.TEST_ENV = process.env.TEST_ENV || "prod";
|
|
75
77
|
`);
|
|
76
78
|
|
|
79
|
+
|
|
77
80
|
// -------------------- environments.json --------------------
|
|
78
81
|
writeFileSafe(path.join(demoDir, "config/environments.json"),
|
|
79
82
|
JSON.stringify({
|