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
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) on how to contribute to Cucumber
14
14
### Changed
15
15
- BREAKING CHANGE: Use appropriate module loading mechanism for configuration files ([#2334](https://github.com/cucumber/cucumber-js/pull/2334))
16
16
- BREAKING CHANGE: Use `await import()` to load all custom formatters and snippet syntaxes ([#2334](https://github.com/cucumber/cucumber-js/pull/2334))
17
+
- BREAKING CHANGE: Use `await import()` for default support code loading ([#2337](https://github.com/cucumber/cucumber-js/pull/2337))
17
18
18
19
### Removed
19
20
- BREAKING CHANGE: Drop support for Node.js 14, 16 and 19 ([#2331](https://github.com/cucumber/cucumber-js/pull/2331))
Copy file name to clipboardExpand all lines: docs/configuration.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,40 +8,20 @@ _**You are reading the documentation in the `main` development branch, which mig
8
8
9
9
You can keep your configuration in a file. Cucumber will look for one of these files in the root of your project, and use the first one it finds:
10
10
11
-
-`cucumber.js`
12
-
-`cucumber.cjs`
13
-
-`cucumber.mjs`
14
11
-`cucumber.json`
15
12
-`cucumber.yaml`
16
13
-`cucumber.yml`
14
+
-`cucumber.js`
15
+
-`cucumber.cjs`
16
+
-`cucumber.mjs`
17
17
18
18
You can also put your file somewhere else and tell Cucumber via the `--config` CLI option:
19
19
20
20
```shell
21
-
$ cucumber-js --config config/cucumber.js
22
-
```
23
-
24
-
Here's a concise example of a configuration file in CommonJS format:
25
-
26
-
```js
27
-
module.exports= {
28
-
default: {
29
-
parallel:2,
30
-
format: ['html:cucumber-report.html']
31
-
}
32
-
}
33
-
```
34
-
35
-
And the same in ESM format:
36
-
37
-
```js
38
-
exportdefault {
39
-
parallel:2,
40
-
format: ['html:cucumber-report.html']
41
-
}
21
+
$ cucumber-js --config config/cucumber.json
42
22
```
43
23
44
-
And the same in JSON format:
24
+
Here's a concise example of a configuration file in JSON format:
45
25
46
26
```json
47
27
{
@@ -61,6 +41,26 @@ default:
61
41
- "html:cucumber-report.html"
62
42
```
63
43
44
+
And the same in JavaScript (ESM) format:
45
+
46
+
```js
47
+
export default {
48
+
parallel: 2,
49
+
format: ['html:cucumber-report.html']
50
+
}
51
+
```
52
+
53
+
And the same in JavaScript (CommonJS) format:
54
+
55
+
```js
56
+
module.exports= {
57
+
default: {
58
+
parallel:2,
59
+
format: ['html:cucumber-report.html']
60
+
}
61
+
}
62
+
```
63
+
64
64
Cucumber also supports the configuration being a string of options in the style of the CLI, though this isn't recommended:
65
65
66
66
```js
@@ -87,7 +87,7 @@ These options can be used in a configuration file (see [above](#files)) or on th
87
87
|`failFast`|`boolean`| No |`--fail-fast`| Stop running tests when a test fails - see [Fail Fast](./fail_fast.md)| false |
88
88
|`format`|`string[]`| Yes |`--format`, `-f`| Name/path and (optionally) output file path of each formatter to use - see [Formatters](./formatters.md)|[]|
89
89
|`formatOptions`|`object`| Yes |`--format-options`| Options to be provided to formatters - see [Formatters](./formatters.md)| {} |
90
-
|`import`|`string[]`| Yes |`--import`, `-i`| Paths to where your support code is, for ESM - see [ESM](./esm.md)|[]|
90
+
|`import`|`string[]`| Yes |`--import`, `-i`| Paths to where your support code is|[]|
91
91
|`language`|`string`| No |`--language`| Default language for your feature files | en |
92
92
|`name`|`string`| No |`--name`| Regular expressions of which scenario names should match one of to be run - see [Filtering](./filtering.md#names)|[]|
93
93
|`order`|`string`| No |`--order`| Run in the order defined, or in a random order | defined |
@@ -123,15 +123,15 @@ For more granular options to control _which scenarios_ from your features should
123
123
By default, Cucumber finds support code files with this logic:
124
124
125
125
* If the features live in a `features` directory (at any level)
126
-
*`features/**/*.(js)`
126
+
*`features/**/*.@(js|cjs|mjs)`
127
127
* Otherwise
128
-
*`<DIR>/**/*.(js)` for each directory containing the selected features
128
+
*`<DIR>/**/*.@(js|cjs|mjs)` for each directory containing the selected features
129
129
130
-
If your files are somewhere else, you can override this by proving your own [glob](https://github.com/isaacs/node-glob), directory or file path to the `require` configuration option:
130
+
If your files are somewhere else, you can override this by proving your own [glob](https://github.com/isaacs/node-glob), directory or file path to the `import` configuration option:
131
131
132
-
- In a configuration file `{ require: ['somewhere-else/support/*.js'] }`
133
-
- On the CLI `$ cucumber-js --require somewhere-else/support/*.js`
132
+
- In a configuration file `{ import: ['somewhere-else/support/*.js'] }`
133
+
- On the CLI `$ cucumber-js --import somewhere-else/support/*.js`
134
134
135
-
Once you specify any `require` options, the defaults described above are no longer applied. The option is repeatable, so you can provide several values and they'll be combined, meaning you can load files from multiple locations.
135
+
Once you specify any `import` options, the defaults described above are no longer applied. The option is repeatable, so you can provide several values and they'll be combined, meaning you can load files from multiple locations.
136
136
137
-
The default behaviour and the `require` option both use the [legacy CommonJS modules API](https://nodejs.org/api/modules.html) to load your files. If your files are native ES modules, you'll need to use the `import` option instead in the same way, and they'll be loaded with the [new ES modules API](https://nodejs.org/api/esm.html). See [ES Modules](./esm.md) for more on using Cucumber in an ESM project.
137
+
The default behaviour and the `import` option both use the [new ES modules API](https://nodejs.org/api/esm.html) to load your files. This should work fine for the majority of cases, but sometimes (e.g. when transpiling with the `require-module` option), you'll need to use the `require` option instead in the same way, and they'll be loaded with the [legacy CommonJS modules API](https://nodejs.org/api/modules.html).
Copy file name to clipboardExpand all lines: src/configuration/validate_configuration.ts
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,11 @@ export function validateConfiguration(
10
10
'`publishQuiet` option is no longer needed, you can remove it from your configuration; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md'
'Use of `require-module` option normally means you should specify your support code paths with `require`; see https://github.com/cucumber/cucumber-js/blob/main/docs/configuration.md#finding-your-code'
0 commit comments