@sridharkikkeri/playwright-common 1.0.12 → 1.0.14

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.
@@ -55,7 +55,7 @@ const packageJson = {
55
55
  'lint:fix': 'eslint . --fix'
56
56
  },
57
57
  dependencies: {
58
- '@sridharkikkeri/playwright-common': '^1.0.12',
58
+ '@sridharkikkeri/playwright-common': '^1.0.14',
59
59
  '@playwright/test': '^1.42.0',
60
60
  'allure-playwright': '^3.4.5'
61
61
  },
@@ -71,12 +71,10 @@ fs.writeFileSync(path.join(projectPath, 'package.json'), JSON.stringify(packageJ
71
71
 
72
72
  // --- CORE BOILERPLATE FILES ---
73
73
 
74
- // src/core/api/BaseApiClient.ts
75
74
  const baseApiClientTs = `import { ApiClient } from '@sridharkikkeri/playwright-common';
76
75
 
77
76
  /**
78
77
  * Project-specific Base API Client.
79
- * Extend this to add custom headers or shared error handling for your app.
80
78
  */
81
79
  export class BaseApiClient extends ApiClient {
82
80
  constructor(baseUrl: string) {
@@ -86,12 +84,11 @@ export class BaseApiClient extends ApiClient {
86
84
  `;
87
85
  fs.writeFileSync(path.join(projectPath, 'src/core/api/BaseApiClient.ts'), baseApiClientTs);
88
86
 
89
- // src/core/pages/BaseComponent.ts
90
87
  const baseComponentTs = `import { Page } from '@playwright/test';
91
88
  import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
92
89
 
93
90
  /**
94
- * Base Component for project-specific reusable UI elements (e.g., Modals, Navbars).
91
+ * Base Component for project-specific reusable UI elements.
95
92
  */
96
93
  export abstract class BaseComponent extends BasePage {
97
94
  constructor(page: Page, orchestrator?: ActionOrchestrator) {
@@ -101,7 +98,6 @@ export abstract class BaseComponent extends BasePage {
101
98
  `;
102
99
  fs.writeFileSync(path.join(projectPath, 'src/core/pages/BaseComponent.ts'), baseComponentTs);
103
100
 
104
- // src/core/utils/ProjectUtils.ts
105
101
  const projectUtilsTs = `/**
106
102
  * Shared utility functions for this specific test project.
107
103
  */
@@ -116,69 +112,108 @@ fs.writeFileSync(path.join(projectPath, 'src/core/utils/ProjectUtils.ts'), proje
116
112
  // --- CONFIGURATION ---
117
113
  const baseConfig = { healingEnabled: true, environment: 'dev', baseUrl: 'https://example.com', apiUrl: 'https://api.example.com', timeout: 30000, retries: 2 };
118
114
  const environments = ['dev', 'qa', 'auto', 'staging', 'prod'];
115
+
119
116
  environments.forEach(env => {
120
- const config = { ...baseConfig, environment: env, baseUrl: \`https://\${env}.example.com\`, apiUrl: \`https://api-\${env}.example.com\` };
121
- fs.writeFileSync(path.join(projectPath, \`framework.config.\${env}.json\`), JSON.stringify(config, null, 2));
117
+ const config = {
118
+ ...baseConfig,
119
+ environment: env,
120
+ baseUrl: `https://${env}.example.com`,
121
+ apiUrl: `https://api-${env}.example.com`
122
+ };
123
+ fs.writeFileSync(path.join(projectPath, `framework.config.${env}.json`), JSON.stringify(config, null, 2));
122
124
  });
123
125
  fs.writeFileSync(path.join(projectPath, 'framework.config.json'), JSON.stringify(baseConfig, null, 2));
124
126
 
125
127
  // playwright.config.ts
126
128
  const playwrightConfig = `import { defineConfig } from '@playwright/test';
127
- export default defineConfig({
128
- testDir: './src/tests',
129
- timeout: 30000,
130
- retries: process.env.CI ? 2 : 0,
131
- workers: process.env.CI ? 1 : undefined,
132
- reporter: [['html'], ['allure-playwright', { outputFolder: 'allure-results' }]],
133
- use: { trace: 'on-first-retry', screenshot: 'only-on-failure' }
134
- }); `;
129
+
130
+ export default defineConfig({
131
+ testDir: './src/tests',
132
+ timeout: 30000,
133
+ retries: process.env.CI ? 2 : 0,
134
+ workers: process.env.CI ? 1 : undefined,
135
+ reporter: [
136
+ ['html'],
137
+ ['allure-playwright', { outputFolder: 'allure-results' }]
138
+ ],
139
+ use: {
140
+ trace: 'on-first-retry',
141
+ screenshot: 'only-on-failure'
142
+ }
143
+ });`;
135
144
  fs.writeFileSync(path.join(projectPath, 'playwright.config.ts'), playwrightConfig);
136
145
 
137
146
  // src/fixtures/fixtures.ts
138
147
  const fixturesTs = `import { test as base } from '@sridharkikkeri/playwright-common';
139
- import { HomePage } from '../pages/HomePage';
140
- export const test = base.extend < { homePage: HomePage } > ({
141
- homePage: async ({ page, orchestrator }, use) => { await use(new HomePage(page, orchestrator)); },
142
- });
143
- export { expect } from '@playwright/test'; `;
148
+ import { HomePage } from '../pages/HomePage';
149
+
150
+ export const test = base.extend<{ homePage: HomePage }>({
151
+ homePage: async ({ page, orchestrator }, use) => {
152
+ await use(new HomePage(page, orchestrator));
153
+ },
154
+ });
155
+
156
+ export { expect } from '@playwright/test';`;
144
157
  fs.writeFileSync(path.join(projectPath, 'src/fixtures/fixtures.ts'), fixturesTs);
145
158
 
146
159
  // Sample Page Object
147
160
  const samplePage = `import { Page } from '@playwright/test';
148
- import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
149
- export class HomePage extends BasePage {
150
- constructor(page: Page, orchestrator?: ActionOrchestrator) { super(page, { pageName: 'HomePage', orchestrator }); }
151
- private readonly searchInput = this.element('[data-testid="search"]');
152
- private readonly searchBtn = this.element('button[type="submit"]');
153
- async search(query: string) {
154
- await this.searchInput.fill(query, 'Enter search query');
155
- await this.searchBtn.click('Click search button');
156
- }
161
+ import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
162
+
163
+ export class HomePage extends BasePage {
164
+ constructor(page: Page, orchestrator?: ActionOrchestrator) {
165
+ super(page, { pageName: 'HomePage', orchestrator });
157
166
  }
158
- `;
167
+
168
+ private readonly searchInput = this.element('[data-testid="search"]');
169
+ private readonly searchBtn = this.element('button[type="submit"]');
170
+
171
+ async search(query: string) {
172
+ await this.searchInput.fill(query, 'Enter search query');
173
+ await this.searchBtn.click('Click search button');
174
+ }
175
+ }
176
+ `;
159
177
  fs.writeFileSync(path.join(projectPath, 'src/pages/HomePage.ts'), samplePage);
160
178
 
161
179
  // Sample Test
162
180
  const sampleTest = `import { test, expect } from '../fixtures/fixtures';
163
- test.describe('HealthEdge Framework Demo', () => {
164
- test('Search functionality with Fixtures', async ({ page, homePage }) => {
165
- await page.goto('https://playwright.dev');
166
- await homePage.search('playwright');
167
- await expect(page).toHaveTitle(/Playwright/);
168
- });
169
- }); `;
181
+
182
+ test.describe('HealthEdge Framework Demo', () => {
183
+ test('Search functionality with Fixtures', async ({ page, homePage }) => {
184
+ await page.goto('https://playwright.dev');
185
+ await homePage.search('playwright');
186
+ await expect(page).toHaveTitle(/Playwright/);
187
+ });
188
+ });`;
170
189
  fs.writeFileSync(path.join(projectPath, 'src/tests/sample.spec.ts'), sampleTest);
171
190
 
172
191
  const sampleI18n = { "login_welcome": "Welcome to HealthEdge" };
173
192
  fs.writeFileSync(path.join(projectPath, 'src/i18n/en.json'), JSON.stringify(sampleI18n, null, 2));
174
193
 
175
194
  const tsConfig = {
176
- compilerOptions: { target: 'ES2020', module: 'commonjs', lib: ['ES2020'], strict: true, esModuleInterop: true, skipLibCheck: true, forceConsistentCasingInFileNames: true, resolveJsonModule: true },
195
+ compilerOptions: {
196
+ target: 'ES2020',
197
+ module: 'commonjs',
198
+ lib: ['ES2020'],
199
+ strict: true,
200
+ esModuleInterop: true,
201
+ skipLibCheck: true,
202
+ forceConsistentCasingInFileNames: true,
203
+ resolveJsonModule: true
204
+ },
177
205
  include: ['src/**/*']
178
206
  };
179
207
  fs.writeFileSync(path.join(projectPath, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
180
208
 
181
- const gitignore = `node_modules /\nallure - results /\nallure - report /\ntest - results /\nplaywright - report /\n.env\n *.log\n`;
209
+ const gitignore = `node_modules/
210
+ allure-results/
211
+ allure-report/
212
+ test-results/
213
+ playwright-report/
214
+ .env
215
+ *.log
216
+ `;
182
217
  fs.writeFileSync(path.join(projectPath, '.gitignore'), gitignore);
183
218
 
184
219
  console.log('✅ Project structure created');
@@ -191,6 +226,6 @@ try {
191
226
  console.log('\n⚠️ Run "npm install" manually in the project directory');
192
227
  }
193
228
 
194
- console.log(`\n🎉 Project ready! Next steps: \n`);
195
- console.log(` cd \${ projectName } `);
196
- console.log(` npm run test: dev\n`);
229
+ console.log(`\n🎉 Project ready! Next steps:\n`);
230
+ console.log(` cd ${projectName}`);
231
+ console.log(` npm run test:dev\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sridharkikkeri/playwright-common",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Production-grade Playwright framework with AI-powered self-healing, visual regression, and enterprise features",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",