@sridharkikkeri/playwright-common 1.0.14 → 1.0.16

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.14',
58
+ '@sridharkikkeri/playwright-common': '^1.0.16',
59
59
  '@playwright/test': '^1.42.0',
60
60
  'allure-playwright': '^3.4.5'
61
61
  },
@@ -69,47 +69,67 @@ const packageJson = {
69
69
 
70
70
  fs.writeFileSync(path.join(projectPath, 'package.json'), JSON.stringify(packageJson, null, 2));
71
71
 
72
- // --- CORE BOILERPLATE FILES ---
72
+ // --- PROFESSIONAL EXTENSION BOILERPLATE ---
73
73
 
74
74
  const baseApiClientTs = `import { ApiClient } from '@sridharkikkeri/playwright-common';
75
-
76
- /**
77
- * Project-specific Base API Client.
78
- */
79
75
  export class BaseApiClient extends ApiClient {
80
- constructor(baseUrl: string) {
81
- super(baseUrl);
82
- }
83
- }
84
- `;
76
+ constructor(baseUrl: string) { super(baseUrl); }
77
+ }`;
85
78
  fs.writeFileSync(path.join(projectPath, 'src/core/api/BaseApiClient.ts'), baseApiClientTs);
86
79
 
80
+ const envConfigTs = `import { ConfigManager } from '@sridharkikkeri/playwright-common';
81
+ export class ProjectConfig extends ConfigManager {
82
+ static getProjectName() { return '${projectName}'; }
83
+ }`;
84
+ fs.writeFileSync(path.join(projectPath, 'src/core/config/ProjectConfig.ts'), envConfigTs);
85
+
86
+ const locTs = `import { Localization } from '@sridharkikkeri/playwright-common';
87
+ export class ProjectLocalization extends Localization {
88
+ static getDefaultLocale() { return 'en'; }
89
+ }`;
90
+ fs.writeFileSync(path.join(projectPath, 'src/core/i18n/ProjectLocalization.ts'), locTs);
91
+
87
92
  const baseComponentTs = `import { Page } from '@playwright/test';
88
93
  import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
89
-
90
- /**
91
- * Base Component for project-specific reusable UI elements.
92
- */
93
94
  export abstract class BaseComponent extends BasePage {
94
95
  constructor(page: Page, orchestrator?: ActionOrchestrator) {
95
96
  super(page, { pageName: 'BaseComponent', orchestrator });
96
97
  }
97
- }
98
- `;
98
+ }`;
99
99
  fs.writeFileSync(path.join(projectPath, 'src/core/pages/BaseComponent.ts'), baseComponentTs);
100
100
 
101
- const projectUtilsTs = `/**
102
- * Shared utility functions for this specific test project.
103
- */
104
- export class ProjectUtils {
105
- static async sleep(ms: number) {
106
- return new Promise(resolve => setTimeout(resolve, ms));
107
- }
108
- }
109
- `;
101
+ const reporterTs = `import { AllureUtil } from '@sridharkikkeri/playwright-common';
102
+ export class ProjectReporter {
103
+ static async logStep(name: string) { console.log(\`[STEP] \${name}\`); }
104
+ }`;
105
+ fs.writeFileSync(path.join(projectPath, 'src/core/reporting/ProjectReporter.ts'), reporterTs);
106
+
107
+ const healingTs = `import { LocatorHealing } from '@sridharkikkeri/playwright-common';
108
+ export class ProjectHealer extends LocatorHealing {
109
+ // Customize project-specific healing logic here
110
+ }`;
111
+ fs.writeFileSync(path.join(projectPath, 'src/core/selfhealing/ProjectHealer.ts'), healingTs);
112
+
113
+ const visualTs = `import { VisualTesting } from '@sridharkikkeri/playwright-common';
114
+ export class ProjectVisuals extends VisualTesting {
115
+ // Custom visual testing overrides
116
+ }`;
117
+ fs.writeFileSync(path.join(projectPath, 'src/core/visual/ProjectVisuals.ts'), visualTs);
118
+
119
+ const wrapperTs = `import { ElementWrapper } from '@sridharkikkeri/playwright-common';
120
+ export class ProjectElement extends ElementWrapper {
121
+ // Add custom interaction logic here
122
+ }`;
123
+ fs.writeFileSync(path.join(projectPath, 'src/core/wrappers/ProjectElement.ts'), wrapperTs);
124
+
125
+ const projectUtilsTs = `export class ProjectUtils {
126
+ static async sleep(ms: number) { return new Promise(resolve => setTimeout(resolve, ms)); }
127
+ }`;
110
128
  fs.writeFileSync(path.join(projectPath, 'src/core/utils/ProjectUtils.ts'), projectUtilsTs);
111
129
 
112
- // --- CONFIGURATION ---
130
+ fs.writeFileSync(path.join(projectPath, 'api-docs/index.html'), `<html><body><h1>API Documentation for ${projectName}</h1><p>Run <code>npm run docs:generate</code> to populate.</p></body></html>`);
131
+
132
+ // --- Standard Project Files ---
113
133
  const baseConfig = { healingEnabled: true, environment: 'dev', baseUrl: 'https://example.com', apiUrl: 'https://api.example.com', timeout: 30000, retries: 2 };
114
134
  const environments = ['dev', 'qa', 'auto', 'staging', 'prod'];
115
135
 
@@ -124,93 +144,46 @@ environments.forEach(env => {
124
144
  });
125
145
  fs.writeFileSync(path.join(projectPath, 'framework.config.json'), JSON.stringify(baseConfig, null, 2));
126
146
 
127
- // playwright.config.ts
128
147
  const playwrightConfig = `import { defineConfig } from '@playwright/test';
129
-
130
148
  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
- }
149
+ testDir: './src/tests', timeout: 30000,
150
+ reporter: [['html'], ['allure-playwright', { outputFolder: 'allure-results' }]],
151
+ use: { trace: 'on-first-retry', screenshot: 'only-on-failure' }
143
152
  });`;
144
153
  fs.writeFileSync(path.join(projectPath, 'playwright.config.ts'), playwrightConfig);
145
154
 
146
- // src/fixtures/fixtures.ts
147
155
  const fixturesTs = `import { test as base } from '@sridharkikkeri/playwright-common';
148
156
  import { HomePage } from '../pages/HomePage';
149
-
150
157
  export const test = base.extend<{ homePage: HomePage }>({
151
- homePage: async ({ page, orchestrator }, use) => {
152
- await use(new HomePage(page, orchestrator));
153
- },
158
+ homePage: async ({ page, orchestrator }, use) => { await use(new HomePage(page, orchestrator)); },
154
159
  });
155
-
156
160
  export { expect } from '@playwright/test';`;
157
161
  fs.writeFileSync(path.join(projectPath, 'src/fixtures/fixtures.ts'), fixturesTs);
158
162
 
159
- // Sample Page Object
160
163
  const samplePage = `import { Page } from '@playwright/test';
161
164
  import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
162
-
163
165
  export class HomePage extends BasePage {
164
- constructor(page: Page, orchestrator?: ActionOrchestrator) {
165
- super(page, { pageName: 'HomePage', orchestrator });
166
- }
167
-
168
- private readonly searchInput = this.element('[data-testid="search"]');
166
+ constructor(page: Page, orchestrator?: ActionOrchestrator) { super(page, { pageName: 'HomePage', orchestrator }); }
169
167
  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
- `;
168
+ async clickSearch() { await this.searchBtn.click('Click Search'); }
169
+ }`;
177
170
  fs.writeFileSync(path.join(projectPath, 'src/pages/HomePage.ts'), samplePage);
178
171
 
179
- // Sample Test
180
172
  const sampleTest = `import { test, expect } from '../fixtures/fixtures';
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
- });
173
+ test('Demo Test', async ({ page, homePage }) => {
174
+ await page.goto('https://playwright.dev');
175
+ await expect(page).toHaveTitle(/Playwright/);
188
176
  });`;
189
177
  fs.writeFileSync(path.join(projectPath, 'src/tests/sample.spec.ts'), sampleTest);
190
178
 
191
- const sampleI18n = { "login_welcome": "Welcome to HealthEdge" };
192
- fs.writeFileSync(path.join(projectPath, 'src/i18n/en.json'), JSON.stringify(sampleI18n, null, 2));
193
-
194
- const tsConfig = {
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
- },
205
- include: ['src/**/*']
206
- };
179
+ fs.writeFileSync(path.join(projectPath, 'src/i18n/en.json'), JSON.stringify({ "welcome": "Hello" }, null, 2));
180
+
181
+ const tsConfig = { compilerOptions: { target: 'ES2020', module: 'commonjs', lib: ['ES2020'], strict: true, esModuleInterop: true, skipLibCheck: true, resolveJsonModule: true }, include: ['src/**/*'] };
207
182
  fs.writeFileSync(path.join(projectPath, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
208
183
 
209
184
  const gitignore = `node_modules/
210
185
  allure-results/
211
186
  allure-report/
212
- test-results/
213
- playwright-report/
214
187
  .env
215
188
  *.log
216
189
  `;
@@ -222,10 +195,6 @@ console.log('\n📦 Installing dependencies...\n');
222
195
  try {
223
196
  execSync('npm install', { cwd: projectPath, stdio: 'inherit' });
224
197
  console.log('\n✅ Dependencies installed');
225
- } catch (error) {
226
- console.log('\n⚠️ Run "npm install" manually in the project directory');
227
- }
198
+ } catch (error) { console.log('\n⚠️ Run "npm install" manually'); }
228
199
 
229
- console.log(`\n🎉 Project ready! Next steps:\n`);
230
- console.log(` cd ${projectName}`);
231
- console.log(` npm run test:dev\n`);
200
+ console.log(`\n🎉 Project ready! cd ${projectName} and 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.14",
3
+ "version": "1.0.16",
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",