0

I included the below code in my conf.js file but the Allure reports are not getting generated.

onPrepare : function() {
    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();
        })
    });
}

Please let me know if I am missing anything.
Thanks,
Srinivas

Tim Zimmermann
  • 6,132
  • 3
  • 30
  • 36
Srinivas
  • 1
  • 1
  • 3
  • Let's debug a little bit. What if you put everything you have under `jasmine.getEnv().afterEach(function(done) {` and move it into an `afterEach` block in one of your tests - do you see the report generated after the test run? Thanks. – alecxe Mar 13 '16 at 11:57
  • I did it and tried. It gives the error as "ReferenceError: allure is not defined" and all the tests are failed. – Srinivas Mar 13 '16 at 13:39
  • I did it and tried. It gives the error as "A Jasmine spec timed out. Resetting the WebDriver Control Flow." Included the following code in my test file.afterEach(function(done) { var AllureReporter = require('jasmine-allure-reporter'); jasmine.getEnv().addReporter(new AllureReporter({ allureReport : { resultsDir : 'allure-results' } })) }); – Srinivas Mar 13 '16 at 14:19

1 Answers1

1

Register a top suite after each function:

onPrepare : function() {
    var AllureReporter = require('jasmine-allure-reporter');
    var reporter = new AllureReporter({
        allureReport : {
            resultsDir : 'allure-results'
        }
    });
    jasmine.getEnv().addReporter(reporter);

    jasmine.getEnv().topSuite().afterEach({fn: function() {
        browser.takeScreenshot().then(function(png) {
            allure.createAttachment('Screenshot', function() {
                return new Buffer(png, 'base64')
            }, 'image/png')();
        })
    }});
}

Not tested.

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • It worked. Thanks for your reply. But I has to make a small change to make it work. Instead of "reporter.createAttachment('Screenshot', function() {", I had to change it as "allure.createAttachment('Screenshot', function() {" – Srinivas Mar 13 '16 at 14:54
  • @Srinivas okay, included that in the answer. Please see http://stackoverflow.com/help/someone-answers. Thanks! – alecxe Mar 13 '16 at 14:55