Generate simple html based on jasmine-allure-reporter

老子叫甜甜 提交于 2019-12-22 00:31:01

问题


I'm using jasmine-allure-reporter and the report is simply awesome. Only complaint over the reporter is that I miss option to enable only failed screenshots to be saved and possibility to send it via e-mail.

I know that is not possible: How to send an email of allure report?

My question is whether I can somehow generate a simple html file with few data based on the allure reports, so that I'll be able to send it via e-mail to relevant people.


回答1:


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:




回答2:


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'
}));


来源:https://stackoverflow.com/questions/42621567/generate-simple-html-based-on-jasmine-allure-reporter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!