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
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,30 @@
2
2
3
3
All notable changes to this project will be documented in this file.
4
4
5
+
## v19.0.1
6
+
7
+
- Fix type members to account for scenario hook names, fixes [#1113](https://github.com/badeball/cypress-cucumber-preprocessor/issues/1113).
8
+
9
+
## v19.0.0
10
+
11
+
Breaking changes:
12
+
13
+
- Run `After(..)` hooks in reversed order of definition. This is in line with how cucumber-js behaves.
14
+
15
+
- Updated all dependencies, including `@cucumber/cucumber` to v10.
16
+
17
+
- String literal attachments are now base64-encoded in JSON reports, ref. [cucumber/cucumber-js#2261](https://github.com/cucumber/cucumber-js/pull/2261).
18
+
19
+
Other changes:
20
+
21
+
- Scenario hooks (`Before(..)` and `After(..)`) are now invoked with an object containing a bunch of relevant data. This is in line with how cucumber-js behaves.
22
+
23
+
- Hooks may now be optionally named. This is in line with how cucumber-js behaves.
24
+
25
+
- Omit outputting internal task to the command log when using `attach(..)`.
26
+
27
+
- Add an [API](docs/json-report.md#attachments-node-environment) for adding attachments from the Node environment, fixes [#1089](https://github.com/badeball/cypress-cucumber-preprocessor/issues/1089).
28
+
5
29
## v18.0.6
6
30
7
31
- Make the compile output play nicer with ESM, relates to [#1093](https://github.com/badeball/cypress-cucumber-preprocessor/issues/1093).
A step definition’s *expression* can either be a regular expression or a [cucumber expression](https://github.com/cucumber/cucumber-expressions#readme). The examples in this section use cucumber expressions. If you prefer to use regular expressions, each *capture group* from the match will be passed as arguments to the step definition’s function.
6
22
7
23
```ts
8
24
Given("I have {int} cukes in my belly", (cukes:number) => {});
9
25
```
10
26
11
-
# Arguments
27
+
##Arguments
12
28
13
29
Steps can be accompanied by [doc strings](https://cucumber.io/docs/gherkin/reference/#doc-strings) or [data tables](https://cucumber.io/docs/gherkin/reference/#data-tables), both which will be passed to the step definition as the last argument, as shown below.
See [here](https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/data_table_interface.md) for `DataTable`'s interface.
36
52
37
-
# Custom parameter types
53
+
##Custom parameter types
38
54
39
55
Custom parameter types can be registered using `defineParameterType()`. They share the same scope as tests and you can invoke `defineParameterType()` anywhere you define steps, though the order of definition is unimportant. The table below explains the various arguments you can pass when defining a parameter type.
40
56
@@ -44,7 +60,7 @@ Custom parameter types can be registered using `defineParameterType()`. They sha
44
60
| `regexp` | A regexp that will match the parameter. May include capture groups.
45
61
|`transformer`| A function or method that transforms the match from the regexp. Must have arity 1 if the regexp doesn't have any capture groups. Otherwise the arity must match the number of capture groups in `regexp`. |
46
62
47
-
# Pending steps
63
+
##Pending steps
48
64
49
65
You can return `"pending"` from a step defintion or a chain to mark a step as pending. This will halt the execution and Cypress will report the test as "skipped". This is generally used for marking steps as "unimplemented" and allows you to commit unfinished work without breaking the test suite.
50
66
@@ -66,7 +82,7 @@ When("a step", () => {
66
82
});
67
83
```
68
84
69
-
# Skipped steps
85
+
##Skipped steps
70
86
71
87
You can return `"skipped"` from a step defintion or a chain to mark a step as pending. This will halt the execution and Cypress will report the test as "skipped". This however is generally used for conditionally short circuiting a test.
72
88
@@ -88,7 +104,7 @@ When("a step", () => {
88
104
});
89
105
```
90
106
91
-
# Nested steps
107
+
##Nested steps
92
108
93
109
You can invoke other steps from a step using `Step()`, as shown below.
94
110
@@ -123,7 +139,11 @@ When("I fill in the entire form", function () {
123
139
});
124
140
```
125
141
126
-
# Scenario hooks
142
+
# Hooks
143
+
144
+
There are two types of hooks, scenario hooks and step hooks, each explained below.
145
+
146
+
## Scenario hooks
127
147
128
148
`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`.
129
149
@@ -148,9 +168,13 @@ Before({ tags: "@foo and @bar" }, function () {
148
168
Before({ tags: "@foo or @bar" }, function () {
149
169
// This hook will be executed before scenarios tagged with @foo or @bar.
// Scenario hooks are invoked with an object containing a bunch of relevant data.
174
+
});
151
175
```
152
176
153
-
# Step hooks
177
+
##Step hooks
154
178
155
179
`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.
156
180
@@ -176,9 +200,22 @@ BeforeStep({ tags: "@foo or @bar" }, function () {
176
200
// This hook will be executed before steps in scenarios tagged with @foo or @bar.
// Step hooks are invoked with an object containing a bunch of relevant data.
181
205
});
182
206
```
183
207
184
208
[^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).
209
+
210
+
## Named hooks
211
+
212
+
Both scenario hooks and step hooks can optionally be named. Names are displayed in the command log, as well as in [messages reports](messages-report.md).
Similar to the browser API explained above, attachments can also be added using a Node API. This is less typical and only required in specific scenarios. This API is available through the `onAfterStep` option in `addCucumberPreprocessorPlugin`, like shown below. The Node API mimicks the options found in the browser API.
66
+
67
+
```ts
68
+
awaitaddCucumberPreprocessorPlugin(on, config, {
69
+
onAfterStep({ wasLastStep, attach }) {
70
+
attach("foobar");
71
+
}
72
+
});
73
+
```
74
+
75
+
By default, text is saved with a MIME type of text/plain. You can also specify a different MIME type.
0 commit comments