0

Using protractor with cucumber and need a plug in or tool (free if possible) that will create a user friendly test report or at least a file that a test report can be generated from. Thank you!

4 Answers 4

3

The easiest thing to do is to compliment your current setup with the free and open-source Serenity/JS.

Serenity/JS is a next generation acceptance testing library, but in the most basic scenario, it can also act as an integration layer between Protractor and Cucumber.

This enables you to:

  • Run your tests in parallel and still get the aggregated, user-friendly test reports.
  • Enhance your test reports with screenshots of your app's UI without any additional plugins.
  • Fix some common problems related to Cucumber/WebDriver ControlFlow synchronisation and inaccurate reporting with just a single config change.
  • Try the Screenplay Pattern in some part of your project while keeping your other tests working as they used to. This way you minimise the risk of disrupting the work of your team while improving your tool set.

The below setup instructions are explained in detail in the manual, and the reports you'll get will look like this:

enter image description here

Setup

Install the serenity-js module from the npm and save it as a development dependency:

npm install serenity-js --save-dev

With the serenity-js module installed, you can update your Protractor configuration file to include:

exports.config = {
    framework: 'custom',
    frameworkPath: require.resolve('serenity-js'), 
    // ...
}

If you're currently using the protractor-cucumber-framework, you can simply replace it with serenity-js.

Report generation

Serenity/JS produces test execution reports in json format and to convert them to html you'll need serenity-cli (which is a node.js wrapper around the Serenity BDD CLI, which in turn is a Java program and you'll need the Java Runtime Environment 7 or newer to run it).

Install serenity-cli and save it as a development dependency:

npm install serenity-cli --save-dev

Next, add the following npm scripts to your package.json file:

 "scripts": {
    "prereport": "serenity update",
    "report":  "serenity run",

    // other scripts ...
  },

With the above setup complete running your protractor tests will produce test reports in the json format together with screenshots under target/site/serenity, and running npm run report will process those intermediary reports and produce the user-friendly HTML version you're after.

Hope this helps,

Jan

5
  • I get E/launcher - Error: Error: EACCES: permission denied, scandir '/etc/cups/ssl' at Error (native) at Object.fs.readdirSync (fs.js:952:18) at GlobSync._readdir (/home/ali/node_modules/cucumber/node_modules/glob/sync.js:288:41) [18:15:41] E/launcher - Process exited with error code 100,Do you have any instructions?
    – Ali-Alrabi
    Apr 29, 2017 at 16:20
  • Hey Ali, if you think think this is related to Serenity/JS could you please submit a ticket on github? Thanks! github.com/jan-molak/serenity-js
    – Jan Molak
    Apr 29, 2017 at 18:50
  • @JanMolak my exports.config already have framework: 'jasmine'. Can I use serenity reports with protractor-jasmine framework?? If yes, how can I do that in my protractot-conf.js file?
    – kvm006
    Jul 18, 2017 at 18:54
  • 1
    Hi there, at the moment Serenity/JS supports Cucumber and Mocha as those libraries provide better support for asynchronous tests and offer easier integration with custom reporters than Jasmine. Jasmine could be supported as well and I'm open to PRs if anyone is interested.
    – Jan Molak
    Jul 18, 2017 at 21:15
  • 1
    Thanks for confirming :)
    – kvm006
    Jul 18, 2017 at 23:29
0

I'm using the cucumberjs-allure-reporter package and it provides a pretty extensive reporting capability. I've been able to create hooks that take screen shots, capture browser logs and network traffic reports after each step allowing me to track quite a bit of information for each test.

Instructions for setting it up is a bit vague, but once you find all of the info, it works like a charm.

0

you can try https://www.npmjs.com/package/cucumber-html-reporter, which integrates well with the Protractor

e.g. HTML Preview of Report with Pie Charts

Screenshot

1
  • Please elaborate. A link is not consider as an answer.
    – sg7
    Mar 11, 2018 at 19:58
-1

https://github.com/igniteram/protractor-cucumber-allure

Use the above repo. It has two different html reports within it. you can also use the hooks to screenshot when there is a failure. I tried it and it works like a charm.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.