Я реализую сценарий CucumberJS, который использует несколько шагов в двух разных файлах определения шагов. Первый шаг устанавливает некоторые переменные в мире, которые должны использоваться шагом в другом файле определения шага.
Переменная устанавливается правильно, но когда шаг в другом файле пытается прочитать ее, она не определена. Любые идеи, как решить эту проблему, кроме слияния файлов определения шага?
пример:
мир.js
var World = function World() {
this.client = '';
};
module.exports.World = World;
тест.функция
Given a variable A
Then some other step
step1.steps.js
module.exports = function () {
this.World = require(process.cwd() + '/test/features/support/world').World;
this.Given(/^a Variable A$/, function () {
this.client = 'abc';
});
};
step2.steps.js
module.exports = function () {
this.World = require(process.cwd() + '/test/features/support/world').World;
this.Then(/^some other step$/, function () {
console.log(this.client);
});
};