Skip to content

Commit 82147ca

Browse files
lackitaclaudedavidjgoss
authored
docs: add ESM example to profiles documentation (#2599)
Co-authored-by: Claude <[email protected]> Co-authored-by: David Goss <[email protected]>
1 parent ce62f23 commit 82147ca

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

docs/profiles.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The short tag is `-p`
1414
cucumber-js -p my_profile
1515
```
1616

17-
## Simple Example
17+
## Simple example
1818

1919
Let's take the common case of having some things a bit different locally than on a continuous integration server. Here's the configuration we've been running locally:
2020

@@ -67,6 +67,31 @@ Now, if we just run `cucumber-js` with no arguments, it will pick up our profile
6767
cucumber-js -p ci
6868
```
6969

70+
## ESM example
71+
72+
When using ES modules, you should use a default export for your default profile and named exports for additional profiles:
73+
74+
```javascript
75+
const common = {
76+
requireModule: ['ts-node/register'],
77+
require: ['support/**/*.ts'],
78+
worldParameters: {
79+
appUrl: process.env.MY_APP_URL || 'http://localhost:3000/'
80+
}
81+
}
82+
83+
export default {
84+
...common,
85+
format: ['progress-bar', 'html:cucumber-report.html'],
86+
}
87+
88+
export const ci = {
89+
...common,
90+
format: ['html:cucumber-report.html'],
91+
publish: true
92+
}
93+
```
94+
7095
## Defining profiles dynamically
7196

7297
If you need to define your profiles dynamically (including asynchronously), you can use the `default` profile key/export to provide an async function that resolves to your profiles. This can be particularly useful in an ESM context where the profiles are static exports. Here's an example:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"Krispin Schulz <[email protected]>",
101101
"Kushal Pisavadia",
102102
"Kyle Moore <[email protected]>",
103+
"lackita (https://github.com/lackita)",
103104
"Leonardo <[email protected]>",
104105
"Long Nguyen (https://github.com/zcmgyu)",
105106
"lopesc <[email protected]>",

0 commit comments

Comments
 (0)