Skip to content

Commit 2f9fcae

Browse files
committed
Re-word example setup
1 parent 8859d0c commit 2f9fcae

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

docs/quick-start.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,42 @@
44
$ npm install @badeball/cypress-cucumber-preprocessor
55
```
66

7-
# Configuration
7+
# Example setup
88

9-
[Configure](https://docs.cypress.io/guides/references/configuration) `specPattern` with `"**/*.feature"`, using EG. `cypress.config.ts`.
9+
[Configure](https://docs.cypress.io/guides/references/configuration) `specPattern` with `"**/*.feature"` and `setupNodeEvents` with a bundler, using EG. `cypress.config.ts`.
1010

11-
```js
11+
```ts
1212
import { defineConfig } from "cypress";
13+
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
14+
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
15+
import createEsbuildPlugin from "@badeball/cypress-cucumber-preprocessor/esbuild";
1316

1417
export default defineConfig({
1518
e2e: {
16-
specPattern: "**/*.feature"
17-
}
19+
specPattern: "**/*.feature",
20+
async setupNodeEvents(
21+
on: Cypress.PluginEvents,
22+
config: Cypress.PluginConfigOptions
23+
): Promise<Cypress.PluginConfigOptions> {
24+
await addCucumberPreprocessorPlugin(on, config);
25+
26+
on(
27+
"file:preprocessor",
28+
createBundler({
29+
plugins: [createEsbuildPlugin(config)],
30+
})
31+
);
32+
33+
// Make sure to return the config object as it might have been modified by the plugin.
34+
return config;
35+
},
36+
},
1837
});
1938
```
2039

21-
Then configure your preferred bundler to process features files. See [examples/](../examples) for how-to using Browserify, Esbuild or Webpack. Esbuild is the recommended bundler if you have no particular requirements (it's by far the fastest).
40+
The example above illustrates how to use the preprocessor together with Esbuild, which is the recommended bundler if you have no particular requirements (it's by far the fastest). See [examples/](../examples) for how-to using Browserify, Esbuild or Webpack, in all language flavors (CJS, ESM, TS).
2241

23-
Read more about configuration options at [docs/configuration.md](configuration.md).
42+
Read more about the preprocessor's configuration options at [docs/configuration.md](configuration.md).
2443

2544
# Write a test
2645

0 commit comments

Comments
 (0)