2

I'm using Protractor and jasmine-allure-reporter. After executing test I am getting the XML files in 'allure-results', from there I am generating the HTML report using the command "allure serve allure-results". While executing this command the html report is getting generated in the 'Temp' folder (%Temp%\8691932647422029\allure-report). I want to generate/save this report locally, how can I do that. Because after the test run I may have to share the html report. Could you please help me on this. Below is the Config.js part for allure-report

onPrepare: function() {
    var AllureReporter = require('jasmine-allure-reporter');

    jasmine.getEnv().addReporter(new AllureReporter());
    jasmine.getEnv().afterEach(function(done){      
      //allure.addEnvironment(Path, 'Chrome'),
      browser.takeScreenshot().then(function (png) {      
      allure.createAttachment('Screenshot', function () {
          return new Buffer(png, 'base64')
        },'image/png')();
        done();
      })
    });
  }
user2176592
  • 119
  • 4
  • 14
  • Could you provide the code that actually shows how you are adding the jasmine allure reporter to protractor? I'm guessing it's in the protractor configuration file. Also, looking at the docs, have you tried to set the `resultDir`? See https://github.com/allure-framework/allure-jasmine/blame/master/README.md#L26 – cnishina Feb 27 '18 at 05:38
  • I have included the code that I am using for adding the jasmine allure reporter. Yes it is in the protractor conf file.I believe resultDir is for the XML files not for HTML one am I correct ?. Here I need the html report in local directory not xml file. – user2176592 Feb 27 '18 at 05:55
  • Looking over the readme, `The Reporter will generate xml files inside of a resultsDir, then we need to generate HTML out of them.` If I was writing this framework, I would probably create the HTML in the same or relative path to the xml directory. Maybe give it a shot? – cnishina Feb 27 '18 at 07:16

1 Answers1

3

Please follow this setup for generating output in your local directory. 'Allure Command Line Tool' will help you to generate allure report.

Install it by running this command npm install allure-commandline --save-dev

After that, add "posttest": "allure generate allure-results --clean -o allure-report" section into your package.json. So when running the test by using npm test , the command mensioned in the posttest will generate report in your local directory. You can refer a sample script section of package.json file below.

"scripts": {
        "pretest": "rm -rf allure-report",
        "test": "protractor conf.js",
        "posttest": "allure generate allure-results --clean -o allure-report || true"
    }

In the posttest section you are refering the output directory location after --clean -o part.

Also change your conf.js file like this and add local directory path in resultsDir section to store generated xml files.

onPrepare: function () {

    var AllureReporter = require('jasmine-allure-reporter');

    //allure report
    jasmine.getEnv().addReporter(new AllureReporter({
        resultsDir: 'allure-results'
    }));

    /* 
     * It will take screenshot after each Jasmine function 'it'
     */        
    jasmine.getEnv().afterEach(function (done) {
        browser.takeScreenshot().then(function (png) {
            allure.createAttachment('Screenshot', function () {
                return new Buffer(png, 'base64')
            }, 'image/png')();
            done();
        })
    });

}

The current setup will generate all the xml files in allure-results and html report in allure-report folder(both are in root directory).

|-allure-results
|-allure-report
|-node_modules
|-src-|-conf.js
      |-package.json

Please refer a sample project in github

jithinkmatthew
  • 890
  • 8
  • 17
  • with this code and command xml files are generating in 'allure-results'. But the html report is not generating in allure-report, this folder is empty. When I tried manually the index.html report is generating in allure-report. But the index.html is displaying as "Loading...". Meaning it is not displaying any test results. – user2176592 Feb 27 '18 at 10:11
  • This is how my script in package.json looks like. "scripts": { "pretest": "rm -rf allure-report", "test": "protractor config.js", "posttest": "allure generate allure-results --clean -o allure-report || true" } – user2176592 Feb 27 '18 at 10:15
  • Sorry for the delay in reply. I am not getting any error. Facing same issue as mentioned in first comment. Can generate the html file by manually executing the command. But the generating html file is not having any data. It shows "404 not found" error. – user2176592 Feb 28 '18 at 06:09
  • 1
    please open the same report in firefox.. :) This may be the issue.. https://stackoverflow.com/questions/23997449/allure-report-nothing-shown-in-chrome – jithinkmatthew Feb 28 '18 at 06:11
  • awsm jitmat :). You are correct, issue was with the browser. I can open in firefox. Thanks :). – user2176592 Feb 28 '18 at 06:30