-
Notifications
You must be signed in to change notification settings - Fork 61
Step retries lose world context #37
Comments
Happened for me, too. Any workaround for this one? |
The line below seems to be related |
Any updates? |
@shkaper the work around I found for this was to store any function / class instances in some custom object inside of the browser object. You would do this in a beforeScenario hook so it gets refreshed on every scenario. So something like this, beforeScenario: function (scenario) {
browser['tools'] = {};
browser['tools']['stuffInstance'] = new Stuff();
} This will ensure you never use the below in your step defs. this.stuffInstance... Instead browser['tools']['stuffInstance'].someMethod |
Can someone provide a reproducible example? |
@christian-bromann below is code to reproduce the error. function fooBar() {
this.getValue = function() {
return 'FooBar';
}
}
function World () {
this.fooBar = new fooBar();
};
module.exports = function () {
this.World = World;
}; step_defs.js this.Given(/^I call a world function with a retry$/, { retry: 1 }, function() {
var foobar = this.fooBar.getValue();
console.log(foobar);
// Triggger a failure so retry is ran
throw new Error('BOOM!');
}) test.feature
The above code will run fine the first time, the second time because of retry 1 this.fooBar.getValue(); Will return undefined. More specifically this.fooBar is undefined. |
The Problem
When a retry is kicked off the functions that were added to the World are no longer available on. They are available in the first run ( as retry has not been kicked off) when the retry happens it looks like it removes the World context from the step definitions.
wdio-cuucmber-framework version: 0.2.5
wdio version: 4.2.11
cucumber version: 1.2.2
The text was updated successfully, but these errors were encountered: