CucumberJS - Error: step expires after 5000 milliseconds in Timer.listOnTimeout (timers.js: 92: 15)

I am new to cucumberjs and just trying to complete my first attempt to run a function. I created a function that is on the cucumber-js github page . I get this error when trying to run it:

Benjamins-MBP: Features Ben $ cucumber.js example.feature Feature: Example Function

As a user cucumber.js I want to have cucumber documentation so that I can focus on creating awesome applications

Scenario: reading documentation # example.feature: 6 Given that I am in the Cucumber.js GitHub repository # StepDefinitions / myStepDefinition.js: 4 Error: step expires in 5000 milliseconds on Timer.listOnTimeout (timers.js: 92: 15) When I go to the README file # StepDefinitions / myStepDefinition.js: 15 Then I should see "Use" as the name of the page # StepDefinitions / myStepDefinition.js: 22

Scripting failure: example.feature: 6 # Script: reading documentation

1 scenario (1 failure) 3 steps (1 unsuccessful, 2 skipped) 0m05.001s

To make this function pass, given that this is an example function on the gizub cucumber-js page, so probably not?

Here is the whole code:

    // features/step_definitions/myStepDefinitions.js

module.exports = function () {
  this.Given(/^I am on the Cucumber.js GitHub repository$/, function (callback) {
    // Express the regexp above with the code you wish you had.
    // `this` is set to a World instance.
    // i.e. you may use this.browser to execute the step:

    this.visit('https://github.com/cucumber/cucumber-js', callback);

    // The callback is passed to visit() so that when the job finished, the next step can
    // be executed by Cucumber.
  });

  this.When(/^I go to the README file$/, function (callback) {
    // Express the regexp above with the code you wish you had. Call callback() at the end
    // of the step, or callback.pending() if the step is not yet implemented:

    callback.pending();
  });

  this.Then(/^I should see "(.*)" as the page title$/, function (title, callback) {
    // matching groups are passed as parameters to the step definition

    var pageTitle = this.browser.text('title');
    if (title === pageTitle) {
      callback();
    } else {
      callback(new Error("Expected to be on page with title " + title));
    }
  });
};

Function:

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 go to the README file
    Then I should see "Usage" as the page title

world.js file:

// 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;
};
+4
3

, 5000 :

protractor.conf.js

cucumberOpts: {
    require: [
        'tests/e2e/support/env.js',
        'main.step.js',
        ...
    ],
    format: 'pretty', // or summary
    keepAlive: false
},

env.js

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

module.exports = configure;

:

test.feature

Feature: test
    I want test wait

    Scenario: Test call wait
        Given I wait "6" seconds

main.step.js

module.exports = function () {
    this.World = require(__base +'tests/e2e/support/world.js').World;

    // I wait "{time}" seconds
    this.Given(/^I wait "?([^"]*)"? seconds$/, function (time) {
        return browser.sleep(time * 1000);
    });

};

world.js

var World, chai, chaiAsPromised;

chai             = require('chai');
chai_as_promised = require('chai-as-promised');

World = function World (callback) {
    chai.use(chai_as_promised);

    this.expect = chai.expect;

    callback();
};

module.exports.World = World;
+8

defineSupportCode, webdriver

defineSupportCode(function({Given, When, Then, setDefaultTimeout}) {

    setDefaultTimeout(60 * 1000);

    Given('I am on the Cucumber.js GitHub repository', function() {

+4

this.Given , promise, - , OSX.

, :

this.Given(/^I am on the Cucumber.js GitHub repository$/, function () {
  // Notice how `callback` is omitted from the parameters
  return this.visit('https://github.com/cucumber/cucumber-js');

  // A promise, returned by zombie.js `visit` method is returned to Cucumber.
});
+3

Source: https://habr.com/ru/post/1621217/


All Articles