All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zegreatrob.jsmints.plugins.wdiotest.allure-reporter.mjs Maven / Gradle / Ivy

There is a newer version: 6.1.90
Show newest version
import allure from "allure-commandline";
import fs from "fs";
import path from "path";

export function configure(config, directories) {
    const allureDataDir = path.resolve(directories.reports, "../../allure-data");
    if (fs.existsSync(allureDataDir)) {
        fs.rmSync(allureDataDir, {recursive: true})
    }

    config.reporters.push(['allure', {
        outputDir: allureDataDir,
    }]);
    const previousAfterTest = config.afterTest
    config.afterTest = async function (test, context, result) {
        if (previousAfterTest) {
            await previousAfterTest.apply(this, arguments)
        }
        if (result.passed) {
            return;
        }
        await browser.takeScreenshot();
    }
    config.onComplete = function () {
        const timeLabel = "allure report generation";
        console.time(timeLabel)
        const generation = allure(
            ['generate', allureDataDir, '--clean', '--output', directories.reports + "allure/report"]
        )
        return new Promise((resolve, reject) => {
            const generationTimeout = setTimeout(
                () => reject(new Error('Could not generate Allure report - timeout')),
                10000)
            generation.on('exit', function (exitCode) {
                clearTimeout(generationTimeout)

                if (exitCode !== 0) {
                    return reject(new Error('Could not generate Allure report - exit code ' + exitCode))
                }
                console.timeEnd(timeLabel)
                console.log('Allure report successfully generated')
                resolve()
            })
        })
    }

    return config;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy