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

I keep getting this error after upgrading to cucumberJs version above.

Failures:

1) Scenario: Get records from DB
 e2e\features\transac.feature:7
   Step: Given I am logged in as "username" with "password"- e2e\features\transac.feature:8
   Step Definition: e2e\steps\loginSteps.js:17
   Message:
     function timed out after 5000 milliseconds

1 scenario (1 failed)
1 step (1 failed)
0m06.608s

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

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

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

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

Here's the env.js file // features/support/env.js

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

module.exports = configure;
pelican
  • 5,846
  • 9
  • 43
  • 67

1 Answers1

0

You have increased the timeout of spec, but I would suggest increasing the overall PageTimeout and Script Timeout.

These timeouts might override the Cucumber default timeout you are setting from env.js file

Try with something like below

specs: ['./features/*.feature'], allScriptsTimeout: 50000, //This is the overall Timeout getPageTimeout: 50000, //This is the Page timeout cucumberOpts : { require : './features/LoginDefinitions.js', format : 'pretty' }

AdityaReddy
  • 3,625
  • 12
  • 25
  • Not working for me; if you run your tests with protractor from a windows command shell and click inside the windows shell (command prompt), you'll pause the command execution; if you then right click inside that same windows shell, the command will resume running and you'll notice that it fails with the same error i.e function timed out after 5000 milliseconds; not sure why that env.js timeout doesn't work – pelican Sep 01 '16 at 13:36
  • Maybe the issue is in how I run the tests? I can do `gulp protractor` or `protractor protractor.conf.js` but I also noticed in some posts online they run their tests with `cucumber-js`; which is the correct way? – pelican Sep 01 '16 at 13:56
  • I run my tests with `protractor protractor.conf.js` with the specs defined under cucumber options ..something like below `framework: 'custom', frameworkPath: require.resolve('protractor-cucumber-framework'), cucumberOpts : { require : './features/LoginDefinitions.js', format : 'pretty' }` – AdityaReddy Sep 02 '16 at 06:07