Javascript CucumberJS-错误:Timer.listOnTimeout(timers.js:92:15)的步骤在5000毫秒后超时
我是cucumberjs新手,刚刚尝试了我第一次尝试运行一个功能。我已经构建了上的功能。我在尝试运行时遇到以下错误: Benjamins MBP:功能Ben$cucumber.js示例。功能功能: 示例功能 作为cucumber.js的用户,我希望有关于cucumber的文档 这样我就可以专注于构建出色的应用程序 场景:阅读文档# 特色:6 假设我在Cucumber.js GitHub存储库中#StepDefinitions/myStepDefinition.js:4 错误:步骤在5000毫秒后超时 在Timer.listOnTimeout(timers.js:92:15) 当我转到自述文件#StepDefinitions/myStepDefinition.js:15时 然后我应该将“用法”作为页面标题#StepDefinitions/myStepDefinition.js:22 失败场景:示例。功能:6#场景:阅读文档 1个场景(1个失败)3个步骤(1个失败,2个跳过)0m05.001s 如果这是github页面上的示例功能,那么您会怎么做才能让这个功能通过呢 以下是所有代码:Javascript CucumberJS-错误:Timer.listOnTimeout(timers.js:92:15)的步骤在5000毫秒后超时,javascript,timer,cucumberjs,Javascript,Timer,Cucumberjs,我是cucumberjs新手,刚刚尝试了我第一次尝试运行一个功能。我已经构建了上的功能。我在尝试运行时遇到以下错误: Benjamins MBP:功能Ben$cucumber.js示例。功能功能: 示例功能 作为cucumber.js的用户,我希望有关于cucumber的文档 这样我就可以专注于构建出色的应用程序 场景:阅读文档# 特色:6 假设我在Cucumber.js GitHub存储库中#StepDefinitions/myStepDefinition.js:4 错误:步骤在5000毫秒后
// 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's 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));
}
});
};
特色:
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文件:
// 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;
};
将步骤定义中给定的替换为承诺所用的语法,是我在两个不同的OSX环境中修复它的原因 以下是有效的promise语法:
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's `visit` method is returned to Cucumber.
});
添加此项以删除5000毫秒: 量角器.conf.js
cucumberOpts: {
require: [
'tests/e2e/support/env.js',
'main.step.js',
...
],
format: 'pretty', // or summary
keepAlive: false
},
var configure = function () {
this.setDefaultTimeout(60 * 1000);
};
module.exports = configure;
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);
});
};
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;
env.js
cucumberOpts: {
require: [
'tests/e2e/support/env.js',
'main.step.js',
...
],
format: 'pretty', // or summary
keepAlive: false
},
var configure = function () {
this.setDefaultTimeout(60 * 1000);
};
module.exports = configure;
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);
});
};
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;
例如:
测试功能
Feature: test
I want test wait
Scenario: Test call wait
Given I wait "6" seconds
main.step.js
cucumberOpts: {
require: [
'tests/e2e/support/env.js',
'main.step.js',
...
],
format: 'pretty', // or summary
keepAlive: false
},
var configure = function () {
this.setDefaultTimeout(60 * 1000);
};
module.exports = configure;
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);
});
};
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;
world.js
cucumberOpts: {
require: [
'tests/e2e/support/env.js',
'main.step.js',
...
],
format: 'pretty', // or summary
keepAlive: false
},
var configure = function () {
this.setDefaultTimeout(60 * 1000);
};
module.exports = configure;
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);
});
};
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;
在我的例子中,我必须在defineSupportCode中设置默认超时,因为尝试在webdriver中修改超时没有任何效果
defineSupportCode(function({Given, When, Then, setDefaultTimeout}) {
setDefaultTimeout(60 * 1000);
Given('I am on the Cucumber.js GitHub repository', function() {
仅仅从参数中删除回调对我来说已经足够了。在
env.js中导出的配置在哪里调用?
nevermind,由于对我这边的env文件的引用不正确,它无法工作。配置被自动调用()