0
cucumberjs --version 1.2.2
protractor --version 4.0.1
Both installed globally via npm 

I tried following these 2 links to set up my Protractor with newer cucumberJs: Protractor-cucumber-framework: https://github.com/mattfritz/protractor-cucumber-framework cucumberJs: https://github.com/cucumber/cucumber-js

Unfortunately, when I run my tests they always pass regardless of whether the tests failed or not.

And sometimes they time out before 5000 milliseconds which I solved by doing this:

exports.config = {
  // set to "custom" instead of cucumber.
  framework: 'custom',

  // path relative to the current config file
  frameworkPath: require.resolve('protractor-cucumber-framework'),

  // relevant cucumber command line options
  cucumberOpts: {
        require: [
          conf.paths.e2e + '/steps/**/*Steps.js',
          conf.paths.e2e + '/support/env.js',
        ],
        format: 'pretty'
      }
};

Please note I included my env.js above in the cucumber options block and here's my env.js content:

// features/support/env.js

var configure = function () {
  this.setDefaultTimeout(60*1000);
};

module.exports = configure;

Also I have this world.js which I'm not sure how to bring into my tests:

// features/support/world.js
var zombie = require('zombie');
function World() {
  this.browser = new zombie(); // this.browser will be available in step definitions

  this.visit = function (url, callback) {
    this.browser.visit(url, callback);
  };
}

module.exports = function() {
  this.World = World;
};

I looked into 'zoombie.js' and it appears to be a headless browser which I DO NOT CARE ABOUT because the protractor team discourages us from using headless browsers like PhantomJS; see: http://www.protractortest.org/#/browser-setup#setting-up-phantomjs ("Note: We recommend against using PhantomJS for tests with Protractor. There are many reported issues with PhantomJS crashing and behaving differently from real browsers.")

I also tried returning the callback inside the Protractor controlflow with: return browser.controlFlow().execute(callback); but that doesn't seem to work instead it throws this error:

function accepts a callback and returns a promise

My step definition file looks like this:

 module.exports = function () {
      this.Given(/^I am logged in as "([^"]*)" for "([^"]*)"$/, function (username, password, callback) {
        return app.getShell().getLogonPage().logonWithoutAngular(username, password, org).then(null, function (error) {
          console.error('Sorry an error occurred: ' + error);
          throw error;
        });
        return browser.controlFlow().execute(callback); //returning the callback within the Protractor controlFlow queue
      });

I guess my biggest confusion is I don't know if I need that world.js to run my tests on the Chrome browser; I don't care about zombie.js headless browser as they're using on the cucumberjs github page: https://github.com/cucumber/cucumber-js

Am I having all of these problems setting up my protractor tests with the newer cucumberJs because of that world.js ? Basically my tests all pass, all green even when I throw in a failing case purposely. Frustrating; hopefully someone can help

pelican
  • 5,846
  • 9
  • 43
  • 67
  • I would suggest to use promises and return them instead of callbacks also for a clean setup you could have a look at this repo - https://github.com/igniteram/protractor-cucumber-allure – Ram Pasala Aug 30 '16 at 18:28
  • Thanks for the link Ram; I'll take a look; but even when I return promises it's not validating against false inputs; a failing test passes – pelican Aug 30 '16 at 19:08

0 Answers0