simple-playwright-framework 0.0.15 β 0.0.17
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 +109 -132
- package/dist/fixtures/data.fixture.js +1 -1
- package/dist/fixtures/index.d.ts +1 -0
- package/dist/fixtures/index.js +12 -2
- package/dist/fixtures/projectConfig.fixture.d.ts +6 -0
- package/dist/fixtures/projectConfig.fixture.js +10 -0
- package/dist/loaders/projectConfig.loader.d.ts +9 -0
- package/dist/loaders/projectConfig.loader.js +41 -0
- package/dist/types/env.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,183 +1,160 @@
|
|
|
1
|
+
π₯ Singleβclick Copyable README
|
|
2
|
+
markdown
|
|
1
3
|
# simple-playwright-framework
|
|
2
4
|
|
|
3
|
-

|
|
4
|
-

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
9
10
|

|
|
10
11
|
|
|
11
|
-
A lightweight
|
|
12
|
-
|
|
13
|
-
API test automation projects.
|
|
12
|
+
A lightweight, modular automation framework built on top of **Microsoft Playwright**.
|
|
13
|
+
It helps teams quickly bootstrap scalable UI and API test automation projects with **clean architecture, reusable fixtures, and ergonomic onboarding**.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
ergonomics while following modern test automation best practices.
|
|
15
|
+
Repository: [GitHub](https://github.com/Udayakumarg/simpleplaywrightframework)
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
---
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
## β¨ Key Features
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
- **Playwright-powered automation** for browsers and APIs
|
|
22
|
+
- **Custom fixtures** for authentication, storage state, and reusable contexts
|
|
23
|
+
- **Scenario loader** for environmentβdriven test data (JSON or API/DB integration)
|
|
24
|
+
- **Provider registry** for flexible login flows (username, email, or custom auth)
|
|
25
|
+
- **Environment-aware configuration** with safe defaults (`prod` fallback)
|
|
26
|
+
- **Reusable helpers** for file upload/download, iframe handling, and API clients
|
|
27
|
+
- **Modern reporting** with Playwright HTML, Allure, and TestRail integration
|
|
28
|
+
- **CLI scaffolding** to generate demo projects with recommended structure
|
|
29
|
+
- **CI/CD ready** with parallel safety and isolated test state
|
|
30
|
+
- **Extensible design**: plug in your own providers, loaders, or reporters
|
|
23
31
|
|
|
24
|
-
|
|
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
|
|
32
|
+
---
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## Installation
|
|
34
|
+
## π¦ Installation
|
|
37
35
|
|
|
38
36
|
### 1. Install Playwright
|
|
39
|
-
|
|
40
|
-
``` bash
|
|
37
|
+
```bash
|
|
41
38
|
npm install --save-dev @playwright/test playwright
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### 2. Install the framework
|
|
45
|
-
|
|
46
|
-
``` bash
|
|
39
|
+
2. Install the framework
|
|
40
|
+
bash
|
|
47
41
|
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:
|
|
42
|
+
π Create a Demo Project
|
|
43
|
+
Use the CLI to scaffold a readyβtoβrun project:
|
|
55
44
|
|
|
56
|
-
|
|
45
|
+
bash
|
|
57
46
|
npx init-demo-project
|
|
58
|
-
|
|
47
|
+
This generates a demo project with fixtures, config, and sample tests.
|
|
59
48
|
|
|
60
|
-
|
|
49
|
+
βΆοΈ Run Tests
|
|
50
|
+
Navigate into the generated project:
|
|
61
51
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Run Tests
|
|
65
|
-
|
|
66
|
-
Navigate into the generated project and run:
|
|
67
|
-
|
|
68
|
-
``` bash
|
|
52
|
+
bash
|
|
69
53
|
cd demo-project
|
|
70
54
|
npx playwright test
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
Run tests with the Playwright UI runner:
|
|
55
|
+
Run with Playwright UI runner:
|
|
74
56
|
|
|
75
|
-
|
|
57
|
+
bash
|
|
76
58
|
npx playwright test --ui
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
------------------------------------------------------------------------
|
|
80
|
-
|
|
81
|
-
## Example Test
|
|
82
|
-
|
|
83
|
-
``` ts
|
|
59
|
+
π§ͺ Example Test
|
|
60
|
+
ts
|
|
84
61
|
import { test, expect } from '@playwright/test';
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
62
|
+
import { scenarioLoader } from 'simple-playwright-framework';
|
|
63
|
+
|
|
64
|
+
test('login works', async ({ page }) => {
|
|
65
|
+
const data = scenarioLoader(__filename).get("validLogin");
|
|
66
|
+
await page.goto(data.baseUrl);
|
|
67
|
+
await page.fill('#username', data.username);
|
|
68
|
+
await page.fill('#password', data.password);
|
|
69
|
+
await page.click('#login');
|
|
70
|
+
await expect(page).toHaveURL(/dashboard/);
|
|
89
71
|
});
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
72
|
+
π Project Structure
|
|
73
|
+
Example demo project:
|
|
74
|
+
|
|
75
|
+
Code
|
|
76
|
+
demo-project
|
|
77
|
+
β
|
|
78
|
+
βββ tests
|
|
79
|
+
β βββ login.spec.ts
|
|
80
|
+
β
|
|
81
|
+
βββ pages
|
|
82
|
+
β βββ login.page.ts
|
|
83
|
+
β
|
|
84
|
+
βββ utils
|
|
85
|
+
β βββ apiClient.ts
|
|
86
|
+
β
|
|
87
|
+
βββ config
|
|
88
|
+
β βββ environments.ts
|
|
89
|
+
β
|
|
90
|
+
βββ auth
|
|
91
|
+
β βββ storageState.json
|
|
92
|
+
β
|
|
93
|
+
βββ playwright.config.ts
|
|
94
|
+
π Environment Configuration
|
|
95
|
+
ts
|
|
96
|
+
export const environments = {
|
|
97
|
+
dev: { baseUrl: "https://dev.example.com" },
|
|
98
|
+
qa: { baseUrl: "https://qa.example.com" },
|
|
99
|
+
prod:{ baseUrl: "https://prod.example.com" }
|
|
100
|
+
};
|
|
101
|
+
Run against different environments without changing test logic.
|
|
97
102
|
|
|
98
|
-
|
|
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
|
|
103
|
+
π Reporting
|
|
104
|
+
Supports:
|
|
116
105
|
|
|
117
|
-
|
|
106
|
+
Playwright HTML reports
|
|
118
107
|
|
|
119
|
-
|
|
108
|
+
Allure reports
|
|
120
109
|
|
|
121
|
-
|
|
110
|
+
TestRail integration
|
|
122
111
|
|
|
123
|
-
|
|
112
|
+
Generate Playwright report:
|
|
124
113
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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.
|
|
114
|
+
bash
|
|
115
|
+
npx playwright show-report
|
|
116
|
+
π Challenges & Solutions
|
|
117
|
+
Compiled JS confusion β moved output to dist and enforced rootβlevel exports
|
|
138
118
|
|
|
139
|
-
|
|
119
|
+
Demo projects bypassing fixtures β documented imports from framework only
|
|
140
120
|
|
|
141
|
-
|
|
121
|
+
Scenario injection limits β iterated scenarios in test bodies, reporting adapted
|
|
142
122
|
|
|
143
|
-
|
|
123
|
+
Environment defaults missing β added safe fallback (prod)
|
|
144
124
|
|
|
145
|
-
|
|
146
|
-
- Allure reports
|
|
147
|
-
- TestRail integrations
|
|
125
|
+
Dependency resolution issues β onboarding scripts install required packages
|
|
148
126
|
|
|
149
|
-
|
|
127
|
+
Report formatting limitations β modernized with inline CSS and branded colors
|
|
150
128
|
|
|
151
|
-
|
|
152
|
-
npx playwright show-report
|
|
153
|
-
```
|
|
129
|
+
Auth provider rigidity β introduced provider registry for flexible login flows
|
|
154
130
|
|
|
155
|
-
|
|
131
|
+
Parallel safety concerns β kept state testβscoped, avoided global mutation
|
|
156
132
|
|
|
157
|
-
|
|
133
|
+
Demo project scaffolding risks β added warnings and safe file writes
|
|
158
134
|
|
|
135
|
+
π€ Contributing
|
|
159
136
|
Contributions are welcome.
|
|
160
137
|
|
|
161
|
-
|
|
138
|
+
Fork the repository
|
|
162
139
|
|
|
163
|
-
|
|
164
|
-
2. Create a feature branch
|
|
165
|
-
3. Commit your changes
|
|
166
|
-
4. Submit a pull request
|
|
140
|
+
Create a feature branch
|
|
167
141
|
|
|
168
|
-
|
|
169
|
-
existing coding conventions.
|
|
142
|
+
Commit your changes
|
|
170
143
|
|
|
171
|
-
|
|
144
|
+
Submit a pull request
|
|
172
145
|
|
|
173
|
-
|
|
146
|
+
Please ensure that code changes include appropriate tests and follow existing coding conventions.
|
|
174
147
|
|
|
148
|
+
π License
|
|
175
149
|
MIT License
|
|
176
150
|
|
|
177
|
-
|
|
151
|
+
π€ Author
|
|
152
|
+
Developed by Udayakumar
|
|
153
|
+
GitHub: https://github.com/Udayakumarg
|
|
178
154
|
|
|
179
|
-
|
|
155
|
+
Code
|
|
180
156
|
|
|
181
|
-
|
|
157
|
+
---
|
|
182
158
|
|
|
183
|
-
|
|
159
|
+
π Just copy everything above into a file named `README.md` in your repo.
|
|
160
|
+
If youβd like, I can also prepare a **shorter npm landing page version** (featur
|
|
@@ -10,7 +10,7 @@ exports.dataFixture = {
|
|
|
10
10
|
let td;
|
|
11
11
|
try {
|
|
12
12
|
td = (0, data_loader_1.loadTestData)(testInfo, envName);
|
|
13
|
-
console.log("Loaded test data:", td, "Type:", Array.isArray(td) ? "array" : typeof td);
|
|
13
|
+
//console.log("Loaded test data:", td, "Type:", Array.isArray(td) ? "array" : typeof td);
|
|
14
14
|
}
|
|
15
15
|
catch (err) {
|
|
16
16
|
console.error(`β loadTestData threw for env '${envName}':`, err);
|
package/dist/fixtures/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Page } from "@playwright/test";
|
|
2
2
|
import { Fixtures } from "../types/fixtures";
|
|
3
3
|
export declare const test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & Fixtures & {
|
|
4
|
+
pc: Record<string, any>;
|
|
4
5
|
authStore: (page: Page, creds: {
|
|
5
6
|
username: string;
|
|
6
7
|
password: string;
|
package/dist/fixtures/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
3
|
+
// framework/src/fixtures/index.ts
|
|
4
|
+
//
|
|
5
|
+
// MODIFIED β added projectConfigFixture alongside existing fixtures.
|
|
6
|
+
// Only this block is new:
|
|
7
|
+
// ...projectConfigFixture,
|
|
8
|
+
// Everything else is unchanged from your original file.
|
|
9
|
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
2
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
11
|
if (k2 === undefined) k2 = k;
|
|
4
12
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -19,13 +27,15 @@ const test_1 = require("@playwright/test");
|
|
|
19
27
|
const envConfig_fixture_1 = require("./envConfig.fixture");
|
|
20
28
|
const data_fixture_1 = require("./data.fixture");
|
|
21
29
|
const testrail_fixture_1 = require("./testrail.fixture");
|
|
22
|
-
const initAuthSession_1 = require("../utils/auth-session/initAuthSession");
|
|
23
30
|
const file_fixture_1 = require("./file.fixture");
|
|
31
|
+
const projectConfig_fixture_1 = require("./projectConfig.fixture"); // β NEW
|
|
32
|
+
const initAuthSession_1 = require("../utils/auth-session/initAuthSession");
|
|
24
33
|
exports.test = test_1.test.extend({
|
|
25
34
|
...envConfig_fixture_1.envConfigFixture,
|
|
26
35
|
...data_fixture_1.dataFixture,
|
|
27
36
|
...testrail_fixture_1.testrailFixture,
|
|
28
37
|
...file_fixture_1.fileFixture,
|
|
38
|
+
...projectConfig_fixture_1.projectConfigFixture, // β NEW
|
|
29
39
|
authStore: async ({ envConfig }, use) => {
|
|
30
40
|
await use(async (page, creds, providerRegistry) => {
|
|
31
41
|
if (!envConfig.authStorage) {
|
|
@@ -37,4 +47,4 @@ exports.test = test_1.test.extend({
|
|
|
37
47
|
});
|
|
38
48
|
var test_2 = require("@playwright/test");
|
|
39
49
|
Object.defineProperty(exports, "expect", { enumerable: true, get: function () { return test_2.expect; } });
|
|
40
|
-
__exportStar(require("../loaders/scenario.loader"), exports); //
|
|
50
|
+
__exportStar(require("../loaders/scenario.loader"), exports); // β NEW
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectConfigFixture = void 0;
|
|
4
|
+
const projectConfig_loader_1 = require("../loaders/projectConfig.loader");
|
|
5
|
+
exports.projectConfigFixture = {
|
|
6
|
+
pc: async ({ page }, use) => {
|
|
7
|
+
const config = (0, projectConfig_loader_1.loadProjectConfig)();
|
|
8
|
+
await use(config);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads and returns the contents of config/projectConfig.json
|
|
3
|
+
* as a plain object. The shape is defined by each project β
|
|
4
|
+
* the framework imposes no type constraints here.
|
|
5
|
+
*
|
|
6
|
+
* @returns Plain object from projectConfig.json
|
|
7
|
+
* @throws If the file is missing or contains invalid JSON
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadProjectConfig(): Record<string, any>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
3
|
+
// framework/src/loaders/projectConfig.loader.ts
|
|
4
|
+
//
|
|
5
|
+
// Loads projectConfig.json from the consuming project's
|
|
6
|
+
// config/ directory. Follows the exact same pattern as
|
|
7
|
+
// envConfig.loader.ts β flat JSON, no env nesting.
|
|
8
|
+
//
|
|
9
|
+
// projectConfig.json is for project-wide constants that are
|
|
10
|
+
// not environment-specific (threshold, schema paths, etc).
|
|
11
|
+
// Anything env-specific belongs in environments.json instead.
|
|
12
|
+
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.loadProjectConfig = loadProjectConfig;
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
/**
|
|
21
|
+
* Loads and returns the contents of config/projectConfig.json
|
|
22
|
+
* as a plain object. The shape is defined by each project β
|
|
23
|
+
* the framework imposes no type constraints here.
|
|
24
|
+
*
|
|
25
|
+
* @returns Plain object from projectConfig.json
|
|
26
|
+
* @throws If the file is missing or contains invalid JSON
|
|
27
|
+
*/
|
|
28
|
+
function loadProjectConfig() {
|
|
29
|
+
const configPath = path_1.default.join(process.cwd(), "config", "projectConfig.json");
|
|
30
|
+
if (!fs_1.default.existsSync(configPath)) {
|
|
31
|
+
throw new Error(`β projectConfig.json not found at ${configPath}\n` +
|
|
32
|
+
` Create config/projectConfig.json in your project root.`);
|
|
33
|
+
}
|
|
34
|
+
const raw = fs_1.default.readFileSync(configPath, "utf-8");
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(raw);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw new Error(`β projectConfig.json contains invalid JSON at ${configPath}\n${e}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/dist/types/env.d.ts
CHANGED
package/package.json
CHANGED