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
: An object with the following keys:tags
: An array of tags used to apply this hook to only specific scenarios.timeout
: A hook-specific timeout, to override the default timeout.
fn
: A function, defined as follows:- The first argument will be the current running scenario.
(See
Cucumber.Api.Scenario
for more information.) - When using the asynchronous callback interface, have one final argument for the callback function.
- The first argument will be the current running scenario.
(See
Multiple After
hooks are executed in the reverse order that they are 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 are defined.
Defines a step.
Aliases: this.Given
, this.When
, this.Then
.
options
: An object with the following keys:timeout
: A step-specific timeout, to override the default timeout.
pattern
: A regex or string pattern to match against a gherkin step.fn
: A function, which should be defined as follows:- Should have one argument for each capture in the regular expression.
- May have an additional argument if the gherkin step has a docstring or data table.
- When using the asynchronous callback interface, have one final argument for the callback function.
Alias of this.defineStep
.
event
: One of the supported event names listed here.options
: An object with the following keys:timeout
: A step-specific timeout, to override the default timeout.
fn
: A function, defined as follows:- The first argument is the object as defined here.
- When using the asynchronous callback interface, have one final argument for the callback function.
Set the default timeout for asynchronous steps. Defaults to 5000
milliseconds.
Alias of this.defineStep
.
Alias of this.defineStep
.
Set a custom world constructor, to override the default world constructor (function () {}
).
Note: The World constructor was made strictly synchronous in v0.8.0.