All support files that export a function will be called with a context that exposes the following methods:
Defines a hook which is run after each scenario.
options
- object with the following keystags
- array of tags used to apply this hook to only specific scenariostimeout
- hook specific timeout to override the default timeout
code
- a javascript function. The first argument will be the current running scenario. See Cucumber.Api.Scenario for more information. May optionally take an additional argument if using the asynchronous callback interface.
Multiple After hooks are executed in the reverse order that they were defined.
Defines a hook which is run before each scenario. Same interface as this.After. Multiple Before hooks are executed in the order that they were defined.
Defines a step. Aliases: this.Given, this.When, this.Then
options
- object with the following keystimeout
- step specific timeout to override the default timeout
pattern
- regex or string pattern to match against a gherkin stepcode
- a javascript function. Should have one argument for each capture in the regular expression. May have an additional argument if the gherkin step has a doc string or data table. Finally may optionally take an additional argument as a callback if using that interface.
Alias of this.defineStep
event
- one of the supported event names listed hereoptions
- object with the following keystimeout
- step specific timeout to override the default timeout
code
- a javascript function. The first argument is the object as defined here. May optionally take an additional argument as a callback if using that interface.
Set the default timeout for asynchronous steps. Default is 5000
milliseconds.
Alias of this.defineStep
Alias of this.defineStep
Set to a custom world constructor to override the default (function () {}
).
Note: The World constructor was made strictly synchronous in v0.8.0.