Generate simple html based on jasmine-allure-reporter

余生颓废 提交于 2019-12-04 21:37:19

Hope you have added this in your conf file:

onPrepare: function () {
    browser.manage().timeouts().implicitlyWait(15000);
    var AllureReporter = require('jasmine-allure-reporter');
    jasmine.getEnv().addReporter(new AllureReporter({
        allureReport: {
            resultsDir: 'allure-results'
        }
    }));
    jasmine.getEnv().afterEach(function (done) {
        browser.takeScreenshot().then(function (png) {
            allure.createAttachment('Screenshot', function () {
                return new Buffer(png, 'base64');
            }, 'image/png')();
            done();
        });
    });

}

After running the files , go to allure-results where you can see the screenshots and xml reports.

Copy-Paste the folder i.e. allure-results to \node_modules\jasmine-allure-reporter where you can see a pom.xml file.

Install Maven in your machine (This is mandatory)

Now from same path i.e. \node_modules\jasmine-allure-reporter run the following command

mvn site -Dallure.results_pattern=allure-results

After Successfull run of above command,

Go to

\node_modules\jasmine-allure-reporter\target\site\allure-maven-plugin

and open index.html

This is how it looks:

The following code works for me. It takes screenshots of only failed tests.

var originalAddExpectationResult = jasmine.Spec.prototype.addExpectationResult;
jasmine.Spec.prototype.addExpectationResult = function () {
    if (!arguments[0]) {
        browser.takeScreenshot().then(function (png) {
            allure.createAttachment('Screenshot', function () {
                return new Buffer(png, 'base64')
            }, 'image/png')();
        })
    }
    return originalAddExpectationResult.apply(this, arguments);
};

var AllureReporter = require('jasmine-allure-reporter');
jasmine.getEnv().addReporter(new AllureReporter({
    resultsDir: 'allure-results'
}));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!