@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.
- package/create-healthedge-tests.js +84 -80
- package/package.json +1 -1
|
@@ -55,7 +55,7 @@ const packageJson = {
|
|
|
55
55
|
'lint:fix': 'eslint . --fix'
|
|
56
56
|
},
|
|
57
57
|
dependencies: {
|
|
58
|
-
'@sridharkikkeri/playwright-common': '^1.0.
|
|
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
|
-
// ---
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
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 = {
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
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
|
|
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!
|
|
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.
|
|
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",
|