forked from Vishnupv160/playwright_Javascript_v1.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-runner.js
31 lines (28 loc) · 1.29 KB
/
test-runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const config = require('./automation-test-config.cjs');
const { rename } = require('fs');
const { execSync } = require('child_process');
let command
const reportDir = './test-results/';
const oldFilePath = reportDir + 'test-execution-reports/index.html';
if (config.testMethodology == 'TDD' && config.needAllureReport) {
command = `npx playwright test ${config.testcase} --project=${config.browserName} && allure generate ./test-results/allure/allure-results/ -o ./test-results/allure/allure-report --clean && allure open ./test-results/allure/allure-report`;
console.log('allure report is generated')
}
else if (config.testMethodology == 'TDD' && (config.needAllureReport == false)) {
command = `npx playwright test ${config.testcase} --project=${config.browserName} `;
}
else {
command = `cucumber-js --tags ${config.tags}`;
}
const reportName = `test_automation_report_${new Date().toISOString().replace(/[-:.T]/g, '').slice(0, -4)}.html`;
const newFilePath = reportDir + 'test-execution-reports/' + reportName;
try {
console.log(command);
execSync(command, { stdio: 'inherit' });
} catch (error) {
console.error('Error:', error);
}
rename(oldFilePath, newFilePath, (err) => {
if (err) throw err;
console.log('Report File Path ', newFilePath)
});