diff --git a/cleanAllureResults.js b/cleanAllureResults.js new file mode 100644 index 0000000..37f2f7c --- /dev/null +++ b/cleanAllureResults.js @@ -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(); diff --git a/copyHistoryFolder.js b/copyHistoryFolder.js new file mode 100644 index 0000000..752c704 --- /dev/null +++ b/copyHistoryFolder.js @@ -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(); diff --git a/package.json b/package.json new file mode 100644 index 0000000..f969636 --- /dev/null +++ b/package.json @@ -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" +} + + + + + + + +