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 CHANGED
@@ -1,183 +1,160 @@
1
+ πŸ“₯ Single‑click Copyable README
2
+ markdown
1
3
  # simple-playwright-framework
2
4
 
3
- ![npm version](https://img.shields.io/npm/v/simple-playwright-framework)
4
- ![npm
5
- downloads](https://img.shields.io/npm/dm/simple-playwright-framework)
6
- ![license](https://img.shields.io/npm/l/simple-playwright-framework)
7
- ![node](https://img.shields.io/node/v/simple-playwright-framework)
8
- ![playwright](https://img.shields.io/badge/Playwright-supported-45ba63?logo=playwright)
5
+ ![npm version](https://img.shields.io/npm/v/simple-playwright-framework)
6
+ ![npm downloads](https://img.shields.io/npm/dm/simple-playwright-framework)
7
+ ![license](https://img.shields.io/npm/l/simple-playwright-framework)
8
+ ![node](https://img.shields.io/node/v/simple-playwright-framework)
9
+ ![playwright](https://img.shields.io/badge/Playwright-supported-45ba63?logo=playwright)
9
10
  ![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen)
10
11
 
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.
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
- The framework focuses on simplicity, maintainability, and developer
16
- ergonomics while following modern test automation best practices.
15
+ Repository: [GitHub](https://github.com/Udayakumarg/simpleplaywrightframework)
17
16
 
18
- Repository: https://github.com/Udayakumarg/simpleplaywrightframework
17
+ ---
19
18
 
20
- ------------------------------------------------------------------------
19
+ ## ✨ Key Features
21
20
 
22
- ## Features
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
- - 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
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
- ``` bash
45
+ bash
57
46
  npx init-demo-project
58
- ```
47
+ This generates a demo project with fixtures, config, and sample tests.
59
48
 
60
- This command scaffolds a demo project with the recommended structure.
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
- ``` bash
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
- test('homepage loads', async ({ page }) => {
87
- await page.goto('https://example.com');
88
- await expect(page).toHaveTitle(/Example/);
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
- ## Project Structure
95
-
96
- Example project generated by the framework:
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
- 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
103
+ πŸ“Š Reporting
104
+ Supports:
116
105
 
117
- ------------------------------------------------------------------------
106
+ Playwright HTML reports
118
107
 
119
- ## Environment Configuration
108
+ Allure reports
120
109
 
121
- Multiple environments can be configured easily.
110
+ TestRail integration
122
111
 
123
- Example:
112
+ Generate Playwright report:
124
113
 
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.
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
- ## Reporting
121
+ Scenario injection limits β†’ iterated scenarios in test bodies, reporting adapted
142
122
 
143
- The framework works seamlessly with:
123
+ Environment defaults missing β†’ added safe fallback (prod)
144
124
 
145
- - Playwright HTML reports
146
- - Allure reports
147
- - TestRail integrations
125
+ Dependency resolution issues β†’ onboarding scripts install required packages
148
126
 
149
- Generate the Playwright report:
127
+ Report formatting limitations β†’ modernized with inline CSS and branded colors
150
128
 
151
- ``` bash
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
- ## Contributing
133
+ Demo project scaffolding risks β†’ added warnings and safe file writes
158
134
 
135
+ 🀝 Contributing
159
136
  Contributions are welcome.
160
137
 
161
- If you would like to contribute:
138
+ Fork the repository
162
139
 
163
- 1. Fork the repository
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
- Please ensure that code changes include appropriate tests and follow
169
- existing coding conventions.
142
+ Commit your changes
170
143
 
171
- ------------------------------------------------------------------------
144
+ Submit a pull request
172
145
 
173
- ## License
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
- ## Author
155
+ Code
180
156
 
181
- Developed by Udayakumar
157
+ ---
182
158
 
183
- GitHub: https://github.com/Udayakumarg
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);
@@ -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;
@@ -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); // βœ… keep scenarioLoader export
50
+ __exportStar(require("../loaders/scenario.loader"), exports); // ← NEW
@@ -0,0 +1,6 @@
1
+ import { Page } from "@playwright/test";
2
+ export declare const projectConfigFixture: {
3
+ pc: ({ page }: {
4
+ page: Page;
5
+ }, use: (config: Record<string, any>) => Promise<void>) => Promise<void>;
6
+ };
@@ -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
+ }
@@ -1,5 +1,6 @@
1
1
  import type { AuthStorageConfig } from "./auth";
2
2
  export interface EnvConfig {
3
+ openAiApiKey: string;
3
4
  baseUrl: string;
4
5
  apiUrl?: string;
5
6
  db?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-playwright-framework",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "A modular Playwright framework with fixtures, loaders, and demo scaffolding.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",