@sridharkikkeri/playwright-common 1.0.13 → 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.13',
58
+ '@sridharkikkeri/playwright-common': '^1.0.16',
59
59
  '@playwright/test': '^1.42.0',
60
60
  'allure-playwright': '^3.4.5'
61
61
  },
@@ -69,116 +69,124 @@ 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
- // src/core/api/BaseApiClient.ts
75
74
  const baseApiClientTs = `import { ApiClient } from '@sridharkikkeri/playwright-common';
76
-
77
- /**
78
- * Project-specific Base API Client.
79
- * Extend this to add custom headers or shared error handling for your app.
80
- */
81
75
  export class BaseApiClient extends ApiClient {
82
- constructor(baseUrl: string) {
83
- super(baseUrl);
84
- }
85
- }
86
- `;
76
+ constructor(baseUrl: string) { super(baseUrl); }
77
+ }`;
87
78
  fs.writeFileSync(path.join(projectPath, 'src/core/api/BaseApiClient.ts'), baseApiClientTs);
88
79
 
89
- // src/core/pages/BaseComponent.ts
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
+
90
92
  const baseComponentTs = `import { Page } from '@playwright/test';
91
93
  import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
92
-
93
- /**
94
- * Base Component for project-specific reusable UI elements (e.g., Modals, Navbars).
95
- */
96
94
  export abstract class BaseComponent extends BasePage {
97
95
  constructor(page: Page, orchestrator?: ActionOrchestrator) {
98
96
  super(page, { pageName: 'BaseComponent', orchestrator });
99
97
  }
100
- }
101
- `;
98
+ }`;
102
99
  fs.writeFileSync(path.join(projectPath, 'src/core/pages/BaseComponent.ts'), baseComponentTs);
103
100
 
104
- // src/core/utils/ProjectUtils.ts
105
- const projectUtilsTs = `/**
106
- * Shared utility functions for this specific test project.
107
- */
108
- export class ProjectUtils {
109
- static async sleep(ms: number) {
110
- return new Promise(resolve => setTimeout(resolve, ms));
111
- }
112
- }
113
- `;
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
+ }`;
114
128
  fs.writeFileSync(path.join(projectPath, 'src/core/utils/ProjectUtils.ts'), projectUtilsTs);
115
129
 
116
- // --- 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 ---
117
133
  const baseConfig = { healingEnabled: true, environment: 'dev', baseUrl: 'https://example.com', apiUrl: 'https://api.example.com', timeout: 30000, retries: 2 };
118
134
  const environments = ['dev', 'qa', 'auto', 'staging', 'prod'];
135
+
119
136
  environments.forEach(env => {
120
- const config = { ...baseConfig, environment: env, baseUrl: `https://${env}.example.com`, apiUrl: `https://api-${env}.example.com` };
137
+ const config = {
138
+ ...baseConfig,
139
+ environment: env,
140
+ baseUrl: `https://${env}.example.com`,
141
+ apiUrl: `https://api-${env}.example.com`
142
+ };
121
143
  fs.writeFileSync(path.join(projectPath, `framework.config.${env}.json`), JSON.stringify(config, null, 2));
122
144
  });
123
145
  fs.writeFileSync(path.join(projectPath, 'framework.config.json'), JSON.stringify(baseConfig, null, 2));
124
146
 
125
- // playwright.config.ts
126
147
  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
- }); `;
148
+ export default defineConfig({
149
+ testDir: './src/tests', timeout: 30000,
150
+ reporter: [['html'], ['allure-playwright', { outputFolder: 'allure-results' }]],
151
+ use: { trace: 'on-first-retry', screenshot: 'only-on-failure' }
152
+ });`;
135
153
  fs.writeFileSync(path.join(projectPath, 'playwright.config.ts'), playwrightConfig);
136
154
 
137
- // src/fixtures/fixtures.ts
138
155
  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'; `;
156
+ import { HomePage } from '../pages/HomePage';
157
+ export const test = base.extend<{ homePage: HomePage }>({
158
+ homePage: async ({ page, orchestrator }, use) => { await use(new HomePage(page, orchestrator)); },
159
+ });
160
+ export { expect } from '@playwright/test';`;
144
161
  fs.writeFileSync(path.join(projectPath, 'src/fixtures/fixtures.ts'), fixturesTs);
145
162
 
146
- // Sample Page Object
147
163
  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
- }
157
- }
158
- `;
164
+ import { BasePage, ActionOrchestrator } from '@sridharkikkeri/playwright-common';
165
+ export class HomePage extends BasePage {
166
+ constructor(page: Page, orchestrator?: ActionOrchestrator) { super(page, { pageName: 'HomePage', orchestrator }); }
167
+ private readonly searchBtn = this.element('button[type="submit"]');
168
+ async clickSearch() { await this.searchBtn.click('Click Search'); }
169
+ }`;
159
170
  fs.writeFileSync(path.join(projectPath, 'src/pages/HomePage.ts'), samplePage);
160
171
 
161
- // Sample Test
162
172
  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
- }); `;
173
+ test('Demo Test', async ({ page, homePage }) => {
174
+ await page.goto('https://playwright.dev');
175
+ await expect(page).toHaveTitle(/Playwright/);
176
+ });`;
170
177
  fs.writeFileSync(path.join(projectPath, 'src/tests/sample.spec.ts'), sampleTest);
171
178
 
172
- const sampleI18n = { "login_welcome": "Welcome to HealthEdge" };
173
- fs.writeFileSync(path.join(projectPath, 'src/i18n/en.json'), JSON.stringify(sampleI18n, null, 2));
179
+ fs.writeFileSync(path.join(projectPath, 'src/i18n/en.json'), JSON.stringify({ "welcome": "Hello" }, null, 2));
174
180
 
175
- const tsConfig = {
176
- compilerOptions: { target: 'ES2020', module: 'commonjs', lib: ['ES2020'], strict: true, esModuleInterop: true, skipLibCheck: true, forceConsistentCasingInFileNames: true, resolveJsonModule: true },
177
- include: ['src/**/*']
178
- };
181
+ const tsConfig = { compilerOptions: { target: 'ES2020', module: 'commonjs', lib: ['ES2020'], strict: true, esModuleInterop: true, skipLibCheck: true, resolveJsonModule: true }, include: ['src/**/*'] };
179
182
  fs.writeFileSync(path.join(projectPath, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
180
183
 
181
- const gitignore = `node_modules /\nallure - results /\nallure - report /\ntest - results /\nplaywright - report /\n.env\n *.log\n`;
184
+ const gitignore = `node_modules/
185
+ allure-results/
186
+ allure-report/
187
+ .env
188
+ *.log
189
+ `;
182
190
  fs.writeFileSync(path.join(projectPath, '.gitignore'), gitignore);
183
191
 
184
192
  console.log('āœ… Project structure created');
@@ -187,10 +195,6 @@ console.log('\nšŸ“¦ Installing dependencies...\n');
187
195
  try {
188
196
  execSync('npm install', { cwd: projectPath, stdio: 'inherit' });
189
197
  console.log('\nāœ… Dependencies installed');
190
- } catch (error) {
191
- console.log('\nāš ļø Run "npm install" manually in the project directory');
192
- }
198
+ } catch (error) { console.log('\nāš ļø Run "npm install" manually'); }
193
199
 
194
- console.log(`\nšŸŽ‰ Project ready! Next steps: \n`);
195
- console.log(` cd \${ projectName } `);
196
- 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.13",
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",