You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
All notable changes to this project will be documented in this file.
4
4
5
+
## Unreleased
6
+
7
+
- Add BeforeStep and AfterStep hooks, fixes [#847](https://github.com/badeball/cypress-cucumber-preprocessor/issues/847).
8
+
5
9
## v17.1.1
6
10
7
11
- Allow generation of JSON reports with hooks (After / Before) even if `baseUrl` is undefined, fixes [#1017](https://github.com/badeball/cypress-cucumber-preprocessor/issues/1017).
Copy file name to clipboardExpand all lines: docs/cucumber-basics.md
+32-1Lines changed: 32 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,7 @@ When("I fill in the entire form", function () {
101
101
});
102
102
```
103
103
104
-
# Hooks
104
+
# Scenario hooks
105
105
106
106
`Before()` and `After()` is similar to Cypress' `beforeEach()` and `afterEach()`, but they can be selected to conditionally run based on the tags of each scenario, as shown below. Furthermore, failure in these hooks does **not** result in remaining tests being skipped. This is contrary to Cypress' `beforeEach` and `afterEach`.
107
107
@@ -128,4 +128,35 @@ Before({ tags: "@foo or @bar" }, function () {
128
128
});
129
129
```
130
130
131
+
# Step hooks
132
+
133
+
`BeforeStep()` and `AfterStep()` are hooks invoked before and after each step, respectively. These too can be selected to conditionally run based on the tags of each scenario, as shown below.
134
+
135
+
> **Note**
136
+
> Contrary to how cucumber-js works, these `AfterStep()` hooks **does not** run if your step fails[^1].
// Step hooks are invoked with an object containing a bunch of relevant data.
159
+
});
160
+
```
161
+
131
162
[^1]: This discrepancy between the preprocessor and cucumber-js is currently considered to be unsolvable, as explained [here](https://github.com/badeball/cypress-cucumber-preprocessor/issues/824#issuecomment-1561492281).
0 commit comments