Skip to content

Feature -> Develop | Allure Report Automation #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cleanAllureResults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import fs from 'fs';
import path from 'path';


const allureResultsDir = path.join(process.cwd(), 'allure-results');


async function cleanAllureResults() {
try {
if (fs.existsSync(allureResultsDir)) {
await fs.promises.rm(allureResultsDir, { recursive: true, force: true });
console.log('Deleted allure-results folder');
} else {
console.log('allure-results folder does not exist');
}
} catch (error) {
console.error('Error deleting allure-results folder:', error);
}
}


cleanAllureResults();
28 changes: 28 additions & 0 deletions copyHistoryFolder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import fs from 'fs-extra';
import path from 'path';


//paths for allure-report and allure-results
const allureReportDir = path.join(process.cwd(), 'allure-report');
const allureResultsDir = path.join(process.cwd(), 'allure-results');
const historyDir = path.join(allureReportDir, 'history');



async function copyHistoryFolder() {
try {
if (await fs.pathExists(historyDir)) {

await fs.ensureDir(allureResultsDir);

await fs.copy(historyDir, path.join(allureResultsDir, 'history'));
console.log('Successfully copied the history folder to allure-results');
} else {
console.log('No history folder found in allure-report');
}
} catch (error) {
console.error('Error copying history folder:', error);
}
}

copyHistoryFolder();
28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"scripts": {
"wdio": "npm run common-steps",
"wdio-test": "wdio run ./wdio.conf.js",
"wdio debug": "cross-env NODE_WDIO_DEBUG=true npm run common-steps",
"wdio is_human": "cross-env NODE_WDIO_IS_HUMAN=true npm run common-steps",
"wdio mac": "cross-env NODE_WDIO_OS=mac npm run common-steps",
"wdio ios": "cross-env NODE_WDIO_OS=ios npm run common-steps",
"wdio windows": "cross-env NODE_WDIO_OS=windows npm run common-steps",
"wdio linux": "cross-env NODE_WDIO_OS=linux npm run common-steps",
"wdio android": "cross-env NODE_WDIO_OS=android npm run common-steps",
"allure:clean": "node cleanAllureResults.js",
"copy-history": "node copyHistoryFolder.js",
"allure:generate": "allure generate allure-results --clean",
"allure:open": "allure open",
"common-steps": "npm run allure:clean && npm run wdio-test || true && npm run copy-history && npm run allure:generate && npm run allure:open"
},

"type": "module"
}