-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pass step specific options to definition function wrapper (#838)
- Loading branch information
1 parent
142ca56
commit ac33ce6
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Feature: Step Wrapper with Options | ||
In order to be able to write more complex step definition wrappers | ||
As a developer | ||
I want Cucumber to provide the "options" object to the wrapping function | ||
|
||
Background: | ||
Given a file named "features/a.feature" with: | ||
""" | ||
Feature: Step with an option | ||
Scenario: Steps | ||
When I run a step with options | ||
""" | ||
And a file named "features/step_definitions/cucumber_steps.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
defineSupportCode(({Then, When}) => { | ||
When(/^I run a step with options$/, {wrapperOptions: {retry: 2}}, function () {}) | ||
}) | ||
""" | ||
And a file named "features/support/setup.js" with: | ||
""" | ||
import {defineSupportCode} from 'cucumber' | ||
defineSupportCode(({setDefinitionFunctionWrapper}) => { | ||
setDefinitionFunctionWrapper(function (fn, options = {}) { | ||
if (options.retry) { | ||
console.log("Max retries: ", options.retry); | ||
} | ||
return fn; | ||
}) | ||
}) | ||
""" | ||
|
||
Scenario: options passed to the step definitions wrapper | ||
When I run cucumber-js | ||
Then the output contains the text: | ||
""" | ||
Max retries: 2 | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters