Cucumber-js: NodeJS example timing out

Created on 30 Mar 2017  Â·  3Comments  Â·  Source: cucumber/cucumber-js

I'm following the example on this page cucumber-js/docs/nodejs_example.md

Sometimes it passes, but I get a lot of timeouts too. Does the example need updating, or is this a problem with the test runner?

NodeJS v6.9.1

"chromedriver": "^2.28.0",
"cucumber": "2.0.0-rc.9",
"selenium-webdriver": "^3.3.0"
Feature: Example feature

    As a user of Cucumber.js
    I want to have documentation on Cucumber
    So that I can concentrate on building awesome applications

  Scenario: Reading documentation
  ✔ Given I am on the Cucumber.js GitHub repository
  ✔ When I click on "CLI"
  ✖ Then I should see "Running specific features"

Failures:

1) Scenario: Reading documentation - features/documentation.feature:6
   Step: Then I should see "Running specific features" - features/documentation.feature:9
   Step Definition: features/step_definitions/browser_steps.js:15
   Message:
     Error: function timed out after 5000 milliseconds
         at Timeout.<anonymous> (node_modules/cucumber/lib/user_code_runner.js:91:22)
         at ontimeout (timers.js:365:14)
         at tryOnTimeout (timers.js:237:5)
         at Timer.listOnTimeout (timers.js:207:5)

1 scenario (1 failed)
3 steps (1 failed, 2 passed)



md5-2a2c7c10e6fd71308dbd83970eac71b5



Feature: Example feature

    As a user of Cucumber.js
    I want to have documentation on Cucumber
    So that I can concentrate on building awesome applications

  Scenario: Reading documentation
  ✖ Given I am on the Cucumber.js GitHub repository
  - When I click on "CLI"
  - Then I should see "Running specific features"

Failures:

1) Scenario: Reading documentation - features/documentation.feature:6
   Step: Given I am on the Cucumber.js GitHub repository - features/documentation.feature:7
   Step Definition: features/step_definitions/browser_steps.js:5
   Message:
     Error: function timed out after 5000 milliseconds
         at Timeout.<anonymous> (node_modules/cucumber/lib/user_code_runner.js:91:22)
         at ontimeout (timers.js:365:14)
         at tryOnTimeout (timers.js:237:5)
         at Timer.listOnTimeout (timers.js:207:5)

1 scenario (1 failed)
3 steps (1 failed, 2 skipped)

Most helpful comment

Edit: Sorry to have bothered you. In 5 minutes of posting this message I found a solution to increase the step timeout described here. Leaving the comment here for anybody who finds this issue
@charlierudolph, where do you increase the timeout? This is the function that I wrote for me to login using auth0

login(userId, password): void {
        let self: any = this;
        self.signInButton.click().then(function () {
            self.password.sendKeys(password)
            // element(by.css('input[name="password"]')).sendKeys(password);
            browser.waitForAngularEnabled(false);
            self.email.sendKeys(userId);
            self.loginSubmitButton.click().then(function() {
                browser.driver.wait(function() {
                    return self.loginConfirmationWindow.isPresent();
                }, 15000).then(function() {
                    return;
                }, function(){
                    console.log(new Error('Login confirmed window did not show up'));
                    return;
                })
                self.loginConfirmationClose.click();
            });

        })
    }

I know that I gave the browser.driver.wait function a timeout of 15 seconds, but that doesn't matter, the step times out with 5 secs.
I then tried to add the following values globally in the config.ts

    allScriptsTimeout: 60000,
    getPageTimeout: 60000,
    setDefaultTimeout: 60000,

Even after all this I still get the following error

 Error: function timed out after 5000 milliseconds
         at Timeout.<anonymous> (/Users/mohamedr2/workspace/test_app/node_modules/cucumber/lib/user_code_runner.js:91:22)
         at ontimeout (timers.js:386:14)
         at tryOnTimeout (timers.js:250:5)
         at Timer.listOnTimeout (timers.js:214:5)

All 3 comments

I confirmed this was working for me. Please try upping your timeout.

Edit: Sorry to have bothered you. In 5 minutes of posting this message I found a solution to increase the step timeout described here. Leaving the comment here for anybody who finds this issue
@charlierudolph, where do you increase the timeout? This is the function that I wrote for me to login using auth0

login(userId, password): void {
        let self: any = this;
        self.signInButton.click().then(function () {
            self.password.sendKeys(password)
            // element(by.css('input[name="password"]')).sendKeys(password);
            browser.waitForAngularEnabled(false);
            self.email.sendKeys(userId);
            self.loginSubmitButton.click().then(function() {
                browser.driver.wait(function() {
                    return self.loginConfirmationWindow.isPresent();
                }, 15000).then(function() {
                    return;
                }, function(){
                    console.log(new Error('Login confirmed window did not show up'));
                    return;
                })
                self.loginConfirmationClose.click();
            });

        })
    }

I know that I gave the browser.driver.wait function a timeout of 15 seconds, but that doesn't matter, the step times out with 5 secs.
I then tried to add the following values globally in the config.ts

    allScriptsTimeout: 60000,
    getPageTimeout: 60000,
    setDefaultTimeout: 60000,

Even after all this I still get the following error

 Error: function timed out after 5000 milliseconds
         at Timeout.<anonymous> (/Users/mohamedr2/workspace/test_app/node_modules/cucumber/lib/user_code_runner.js:91:22)
         at ontimeout (timers.js:386:14)
         at tryOnTimeout (timers.js:250:5)
         at Timer.listOnTimeout (timers.js:214:5)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bmsoko picture bmsoko  Â·  7Comments

igniteram picture igniteram  Â·  7Comments

jfstephe picture jfstephe  Â·  4Comments

travi picture travi  Â·  5Comments

pellekrogholt picture pellekrogholt  Â·  3Comments