Skip to content

Commit 513b46f

Browse files
Merge branch 'main' into cr-depfix
# Conflicts: # yarn.lock
2 parents a3a4f75 + 295c91a commit 513b46f

27 files changed

+842
-1146
lines changed

.mocharc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ colors: true
22
file:
33
- test/test_helper.ts
44
full-trace: true
5+
forbid-only: true
6+
forbid-pending: true
57
recursive: true
68
reporter: dot
79
require: 'ts-node/register'

CHANGELOG.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
99
----
1010
## [Unreleased] (In Git)
1111

12+
See the [migration guide](./docs/migration.md) for details of how to migrate from 7.x.x to 8.x.x
13+
1214
### Breaking changes
1315

1416
* Drop support for Node.js 10 and 15, add support for Node.js 16
15-
* Remove deprecated `--retryTagFilter` option (the correct option is `--retry-tag-filter`)
17+
* Remove deprecated `--retryTagFilter` option (the correct option is `--retry-tag-filter`)
18+
* Remove `setDefinitionFunctionWrapper` and step definition option `wrapperOptions`
1619

1720
### Added
1821

@@ -25,7 +28,9 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
2528
### Fixed
2629

2730
* Prevent duplicate scenario execution where the same feature is targeted in multiple line expressions ([#1706](https://github.com/cucumber/cucumber-js/issues/1706))
28-
* Fixed reports banner to point to [new docs](https://cucumber.io/docs/cucumber/environment-variables/) about environment variables
31+
* Fixed reports banner to point to [new docs](https://cucumber.io/docs/cucumber/environment-variables/) about environment variables
32+
* Re-add color functions for use with custom formatters [1582](https://github.com/cucumber/cucumber-js/issues/1582)
33+
* IParameterTypeDefinition regexp fix [1702](https://github.com/cucumber/cucumber-js/issues/1702)
2934

3035
## [7.3.0] (2021-06-17)
3136

CONTRIBUTING.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ Before anything else, thank you. Thank you for taking some of your precious time
55
## Setup
66

77
* install [Node.Js](https://nodejs.org/en/) and [Yarn](https://yarnpkg.com/)
8-
* `yarn install`
8+
* `yarn install` - Install dependencies
9+
* `yarn test` - Compile typescript and run the tests
910

1011
## Tests
1112

12-
See the `package.json` scripts section for how to run each category of tests.
13+
Now type `yarn run` or see the `package.json` scripts section for how to run each category of tests.
1314

1415
* lint - `yarn lint`
1516
* [prettier](https://github.com/prettier/prettier)

dependency-lint.yml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ ignoreErrors:
2020
- '@typescript-eslint/eslint-plugin' # peer dependency of standard-with-typescript
2121
- '@typescript-eslint/parser' # peer dependency of @typescript-eslint/eslint-plugin
2222
- '@types/*' # type definitions
23-
- bluebird # features/generator_step_definitions.feature
2423
- coffeescript # features/compiler.feature
2524
- eslint-config-prettier # .eslintrc.yml - extends - prettier
2625
- eslint-config-standard-with-typescript # .eslintrc.yml - extends - standard-with-typescript

docs/migration.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
# Migrating to cucumber-js 7.x.x
1+
# Migrating from 7.x.x to 8.x.x
2+
3+
## Removal of setDefinitionFunctionWrapper
4+
5+
If this was used to wrap generator functions, please transition to using async / await.
6+
If this was used to wrap step definitions, please use `BeforeStep` / `AfterStep` hooks instead.
7+
If you had other use cases, please create an issue.
8+
9+
# Migrating from 6.x.x to 7.x.x
210

311
## Package Name
412

513
cucumber-js is now published at `@cucumber/cucumber` instead of `cucumber`. To upgrade, you'll need to remove the old package and add the new one:
6-
14+
715
```shell
816
$ npm rm cucumber
917
$ npm install --save-dev @cucumber/cucumber
10-
```
11-
18+
```
19+
1220
You'll need to update any `import`/`require` statements in your support code to use the new package name.
1321

1422
(The executable is still `cucumber-js` though.)

docs/support_files/api_reference.md

-32
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ Aliases: `Given`, `When`, `Then`.
112112
* `pattern`: A regex or string pattern to match against a gherkin step.
113113
* `options`: An object with the following keys:
114114
- `timeout`: A step-specific timeout, to override the default timeout.
115-
- `wrapperOptions`: Step-specific options that are passed to the definition function wrapper.
116115
* `fn`: A function, which should be defined as follows:
117116
- Should have one argument for each capture in the regular expression.
118117
- May have an additional argument if the gherkin step has a docstring or data table.
@@ -132,37 +131,6 @@ Set the default timeout for asynchronous steps. Defaults to `5000` milliseconds.
132131

133132
---
134133

135-
#### `setDefinitionFunctionWrapper(wrapper)`
136-
137-
Set a function used to wrap step / hook definitions.
138-
139-
The `wrapper` function is expected to take 2 arguments:
140-
141-
- `fn` is the original function defined for the step - needs to be called in order for the step to be run.
142-
- `options` is the step specific `wrapperOptions` and may be undefined.
143-
144-
A common use case is attaching a screenshot on step failure - this would typically look something like (for a promise-based setup):
145-
146-
```javascript
147-
setDefinitionFunctionWrapper(function(fn, options) {
148-
return function(...args) {
149-
// call original function with correct `this` and arguments
150-
// ensure return value of function is returned
151-
return fn.apply(this, args)
152-
.catch(error => {
153-
// call a method on world
154-
this.doScreenshot();
155-
// rethrow error to avoid swallowing failure
156-
throw error;
157-
});
158-
}
159-
})
160-
```
161-
162-
When used, the result is wrapped again to ensure it has the same length of the original step / hook definition.
163-
164-
---
165-
166134
#### `setWorldConstructor(constructor)`
167135

168136
Set a custom world constructor, to override the default world constructor:

docs/support_files/step_definitions.md

-30
Original file line numberDiff line numberDiff line change
@@ -69,36 +69,6 @@ When(/^I view my profile$/, function () {
6969
});
7070
```
7171

72-
73-
## Definition function wrapper
74-
75-
If you would like to wrap step or hook definitions in with some additional logic you can use `setDefinitionFunctionWrapper(fn)`. The definitions will be wrapped after they have all been loaded but before the tests begin to run. One example usage is wrapping generator functions to return promises. Cucumber will do an additional stage of wrapping to ensure the function retains its original length.
76-
77-
```javascript
78-
// features/step_definitions/file_steps.js
79-
const { Then } = require('@cucumber/cucumber');
80-
const assert = require('assert');
81-
const mzFs = require('mz/fs');
82-
83-
Then(/^the file named (.*) is empty$/, function *(fileName) {
84-
contents = yield mzFs.readFile(fileName, 'utf8');
85-
assert.equal(contents, '');
86-
});
87-
88-
// features/support/setup.js
89-
const { setDefinitionFunctionWrapper } = require('@cucumber/cucumber');
90-
const isGenerator = require('is-generator');
91-
const Promise = require('bluebird');
92-
93-
setDefinitionFunctionWrapper(function (fn) {
94-
if (isGenerator.fn(fn)) {
95-
return Promise.coroutine(fn);
96-
} else {
97-
return fn;
98-
}
99-
});
100-
```
101-
10272
## Pending steps
10373

10474
Each interface has its own way of marking a step as pending

features/generator_step_definitions.feature

-61
This file was deleted.

features/step_wrapper_with_options.feature

-35
This file was deleted.

package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@
176176
"@cucumber/messages": "^16.0.1",
177177
"@cucumber/tag-expressions": "^3.0.1",
178178
"assertion-error-formatter": "^3.0.0",
179-
"bluebird": "^3.7.2",
180179
"capital-case": "^1.0.4",
181180
"cli-table3": "^0.6.0",
182181
"colors": "^1.4.0",
@@ -187,7 +186,6 @@
187186
"figures": "^3.2.0",
188187
"glob": "^7.1.6",
189188
"indent-string": "^4.0.0",
190-
"is-generator": "^1.0.3",
191189
"is-stream": "^2.0.0",
192190
"knuth-shuffle-seeded": "^1.0.6",
193191
"mz": "^2.7.0",
@@ -198,15 +196,13 @@
198196
"stacktrace-js": "^2.0.2",
199197
"string-argv": "^0.3.1",
200198
"tmp": "^0.2.1",
201-
"util-arity": "^1.1.0",
202199
"verror": "^1.10.0"
203200
},
204201
"devDependencies": {
205202
"@cucumber/compatibility-kit": "7.0.0",
206203
"@cucumber/message-streams": "2.1.0",
207204
"@cucumber/query": "10.1.0",
208205
"@sinonjs/fake-timers": "7.1.2",
209-
"@types/bluebird": "3.5.35",
210206
"@types/chai": "4.2.19",
211207
"@types/dirty-chai": "2.0.2",
212208
"@types/express": "4.17.12",
@@ -245,6 +241,7 @@
245241
"mustache": "4.2.0",
246242
"nyc": "15.1.0",
247243
"prettier": "2.3.2",
244+
"reindent-template-literals": "^1.0.0",
248245
"semver": "7.3.5",
249246
"sinon": "11.1.1",
250247
"sinon-chai": "3.7.0",

src/cli/helpers_spec.ts

-8
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ describe('helpers', () => {
135135
stepDefinitions: [
136136
new StepDefinition({
137137
code: noopFunction,
138-
unwrappedCode: noopFunction,
139138
id: '0',
140139
line: 9,
141140
options: {},
@@ -173,7 +172,6 @@ describe('helpers', () => {
173172
stepDefinitions: [
174173
new StepDefinition({
175174
code: noopFunction,
176-
unwrappedCode: noopFunction,
177175
id: '0',
178176
line: 9,
179177
options: {},
@@ -211,7 +209,6 @@ describe('helpers', () => {
211209
beforeTestCaseHookDefinitions: [
212210
new TestCaseHookDefinition({
213211
code: noopFunction,
214-
unwrappedCode: noopFunction,
215212
id: '0',
216213
line: 3,
217214
options: {
@@ -223,15 +220,13 @@ describe('helpers', () => {
223220
afterTestCaseHookDefinitions: [
224221
new TestCaseHookDefinition({
225222
code: noopFunction,
226-
unwrappedCode: noopFunction,
227223
id: '1',
228224
line: 7,
229225
options: {},
230226
uri: 'features/support/hooks.js',
231227
}),
232228
new TestCaseHookDefinition({
233229
code: noopFunction,
234-
unwrappedCode: noopFunction,
235230
id: '2',
236231
line: 11,
237232
options: {},
@@ -285,7 +280,6 @@ describe('helpers', () => {
285280
beforeTestRunHookDefinitions: [
286281
new TestRunHookDefinition({
287282
code: noopFunction,
288-
unwrappedCode: noopFunction,
289283
id: '0',
290284
line: 3,
291285
options: {},
@@ -295,15 +289,13 @@ describe('helpers', () => {
295289
afterTestRunHookDefinitions: [
296290
new TestRunHookDefinition({
297291
code: noopFunction,
298-
unwrappedCode: noopFunction,
299292
id: '1',
300293
line: 7,
301294
options: {},
302295
uri: 'features/support/run-hooks.js',
303296
}),
304297
new TestRunHookDefinition({
305298
code: noopFunction,
306-
unwrappedCode: noopFunction,
307299
id: '2',
308300
line: 11,
309301
options: {},

0 commit comments

Comments
 (0)