1
votes

I am running a Protractor cucumber test and trying to generate report using protractor-multiple-cucumber-html-reporter-plugin.

But when I am using format:json:result.json in the config file the browser(chrome) immediately closes as soon as the test starts running and it shows all the test cases passed in the report.

But I wrote the scenarios in such a way that some test cases should fail.This only happens when I using format:json:result.json in cucumberOpts.

When I am using format:'pretty', browser works fine and it shows running of all the test cases and also it shows correct number of test cases passed and failed.

Please find my config file

const path = require('path');
exports.config = {
directConnect: true,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
cucumberOpts: {
    require: [
         'maths.js',
    ],
    // Tell CucumberJS to save the JSON report
    format: 'json:.tmp/results.json',
    strict: true
},

specs: [
    '*.feature'
],

multiCapabilities: [{
    browserName: 'chrome',
    shardTestFiles: true,
    maxInstances: 2,
    chromeOptions: {
        args: ['disable-infobars']
    }
}],

// Here the magic happens
plugins: [{
    package: 'protractor-multiple-cucumber-html-reporter-plugin',
    options:{
         automaticallyGenerateReport: true,
         removeExistingJsonReportFile: true
    }
}]

};

2
What Cucumber version are you using? - Razvan
cucumber 1.3.2 .I also tried cucumber 2 - doe
Can you add also some step definitions? I assume the issue is in the way you have implemented the steps. - Razvan
Please find my step_definition file in jsfiddle.net/kr66sh6s/1 - doe

2 Answers

0
votes

When you are calling callback() function in a step, cucumber runs that step but waits for protractor to finish it. Protractor runs asynchronously so you have to build the step like:

this.Then(/^I title contains angularjs$/, function () {
    // Write code here that turns the phrase above into concrete actions
    return browser.getCurrentUrl().then(function (text) {
      expect(text).to.eventually.contains('nonAngular');
    })
  });

Also you need to add in cucumberOpts:

require: "./path/to/step_definition/*.js",
0
votes

Try adding the following to the conf.js resolved my issue

onPrepare: function () {        
    browser.ignoreSynchronization = true;       
    browser.waitForAngular();           
    browser.driver.manage().timeouts().implicitlyWait(30000);       
}