1

I am currently using protractor, cucumber and chai/chai-as-promised for my automated tests. My current code is using protractor 1.8.0 and I would like to update it to the most recent version. The problem is that the most recent version of protractor doesn't support cucumber.

To use cucumber as your framework, protractor (http://angular.github.io/protractor/#/frameworks) points you to using protractor-cucumber-framework (https://github.com/mattfritz/protractor-cucumber-framework). I have tried integrating this with my current code and some smaller example projects with no luck at getting them working. The main error I get is:

Error: Step timed out after 5000 milliseconds at Timer.listOnTimeout (timers.js:92:15)

I have tried changing the default timeout globally as cucumber suggests by:// features/support/env.js

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

module.exports = configure;

But I seem to be missing something with my setup.

So, does anyone know of a good example that can show me the proper setup for the new protractor/cucumber framework? If not, does anyone know of an example that shows how to change the default timeout globally?

yvesmancera
  • 2,915
  • 5
  • 24
  • 33
Otto
  • 33
  • 1
  • 6

2 Answers2

7

You should add

this.setDefaultTimeout(60000);

to one of your step_def files. For example:

module.exports = function () {

    this.setDefaultTimeout(60000);
    this.After(function (callback) { ... } 

}

Or you should add //features/support/env.js to

cucumberOpts:{require: ['//features/support/env.js']}

to array with your stepDefinition files

bwegs
  • 3,769
  • 2
  • 30
  • 33
Ivan
  • 86
  • 2
  • Thanks, I did the second suggestion and it worked. Here is another example I found as well that elaborates on what you said. http://stackoverflow.duapp.com/questions/34409724/cucumberjs-error-step-timed-out-after-5000-milliseconds-at-timer-listontimeou – Otto Jan 19 '16 at 19:00
2

thx to @Ivan, with cucumber-protractor-framework and typescript:

in protractor.conf.js

cucumberOpts: {
    compiler: "ts:ts-node/register",
    require: [
      './src/env.ts', //<- added
      './src/**/*.steps.ts'
    ]
  },

in src/env.ts:

import {setDefaultTimeout} from 'cucumber';

setDefaultTimeout(9001);
ya_dimon
  • 3,483
  • 3
  • 31
  • 42