Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

cucumber-js now supports BeforeStep and AfterStep hooks #653

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions content/docs/cucumber/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ end
{{% block "javascript" %}}Cucumber.js does not support `Around` hooks.{{% /block %}}

## Step hooks
{{% text "java,kotlin,scala" %}}
{{% text "java,kotlin,scala,javascript" %}}
Step hooks invoked before and after a step. The hooks have 'invoke around' semantics. Meaning that if a `BeforeStep`
hook is executed the `AfterStep` hooks will also be executed regardless of the result of the step. If a step did not
pass, the following step and its hooks will be skipped.
Expand Down Expand Up @@ -469,7 +469,17 @@ BeforeStep { scenario: Scenario =>
```
{{% /text %}}

{{% text "javascript" %}}Cucumber.js does not support `BeforeStep` hooks.{{% /text %}}
{{% text "javascript" %}}
```javascript
BeforeStep(function({pickle, pickleStep, gherkinDocument, testCaseStartedId, testStepId}) {
// doSomething
})

BeforeStep({tags: "@foo"}, function() {
// apply this hook to only specific scenarios
})
```
{{% /text %}}

### AfterStep

Expand Down Expand Up @@ -516,7 +526,13 @@ AfterStep { scenario: Scenario =>

{{% /block %}}

{{% block "javascript" %}}Cucumber.js does not support `AfterStep` hooks.{{% /block %}}
{{% block "javascript" %}}
```javascript
AfterStep(function({pickle, pickleStep, gherkinDocument, result, testCaseStartedId, testStepId}) {
// doSomething
})
```
{{% /block %}}

## Conditional hooks

Expand Down