Skip to content

Commit afc9965

Browse files
Add support for Cypress v10
Co-authored-by: Anthony Champagne <[email protected]>
1 parent 3777950 commit afc9965

File tree

71 files changed

+1015
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1015
-257
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ $ npm install @badeball/cypress-cucumber-preprocessor
1818
The preprocessor (with its dependencies) parses Gherkin documents and allows you to write tests as shown below.
1919

2020
```cucumber
21-
# cypress/integration/duckduckgo.feature
21+
# cypress/e2e/duckduckgo.feature
2222
Feature: duckduckgo.com
2323
Scenario: visting the frontpage
2424
When I visit duckduckgo.com
2525
Then I should see a search bar
2626
```
2727

2828
```ts
29-
// cypress/integration/duckduckgo.ts
29+
// cypress/e2e/duckduckgo.ts
3030
import { When, Then } from "@badeball/cypress-cucumber-preprocessor";
3131

3232
When("I visit duckduckgo.com", () => {

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Every configuration option has a similar key which can be use to override it, sh
4343

4444
| JSON path | Environment key | Example(s) |
4545
|--------------------|-------------------|------------------------------------------|
46-
| `stepDefinitions` | `stepDefinitions` | `cypress/integration/[filepath].{js,ts}` |
46+
| `stepDefinitions` | `stepDefinitions` | `[filepath].{js,ts}` |
4747
| `messages.enabled` | `messagesEnabled` | `true`, `false` |
4848
| `messages.output` | `messagesOutput` | `cucumber-messages.ndjson` |
4949
| `json.enabled` | `jsonEnabled` | `true`, `false` |

docs/quick-start.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ $ npm install @badeball/cypress-cucumber-preprocessor
66

77
# Configuration
88

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

11-
```json
12-
{
13-
"testFiles": "**/*.feature"
14-
}
11+
```js
12+
import { defineConfig } from "cypress";
13+
14+
export default defineConfig({
15+
e2e: {
16+
specPattern: "**/*.feature"
17+
}
18+
});
1519
```
1620

1721
Configure your preferred bundler to process features files, with examples for
@@ -24,18 +28,18 @@ Read more about configuration options at [docs/configuration.md](configuration.m
2428

2529
# Write a test
2630

27-
Write Gherkin documents anywhere in your configured integration folder (defaults to `cypress/integration`) and add a file for type definitions with a corresponding name (read more about how step definitions are resolved in [docs/step-definitions.md](step-definitions.md)). Reading [docs/cucumber-basics.md](cucumber-basics.md) is highly recommended.
31+
Write Gherkin documents and add a file for type definitions with a corresponding name (read more about how step definitions are resolved in [docs/step-definitions.md](step-definitions.md)). Reading [docs/cucumber-basics.md](cucumber-basics.md) is highly recommended.
2832

2933
```cucumber
30-
# cypress/integration/duckduckgo.feature
34+
# cypress/e2e/duckduckgo.feature
3135
Feature: duckduckgo.com
3236
Scenario: visting the frontpage
3337
When I visit duckduckgo.com
3438
Then I should see a search bar
3539
```
3640

3741
```ts
38-
// cypress/integration/duckduckgo.ts
42+
// cypress/e2e/duckduckgo.ts
3943
import { When, Then } from "@badeball/cypress-cucumber-preprocessor";
4044

4145
When("I visit duckduckgo.com", () => {

docs/state-management.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Please note that if you use arrow functions, you won’t be able to share state
2323
Even though `setWorldConstructor` isn't implemented, it's behavior can be closely replicated like shown below.
2424

2525
```gherkin
26-
# cypress/integration/math.feature
26+
# cypress/e2e/math.feature
2727
Feature: Replicating setWorldConstructor()
2828
Scenario: easy maths
2929
Given a variable set to 1
@@ -32,7 +32,7 @@ Feature: Replicating setWorldConstructor()
3232
```
3333

3434
```ts
35-
// cypress/support/index.ts
35+
// cypress/support/e2e.ts
3636
beforeEach(function () {
3737
const world = {
3838
variable: 0,

docs/step-definitions.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ Step definitions are resolved using search paths that are configurable through t
55
```json
66
{
77
"stepDefinitions": [
8-
"cypress/integration/[filepath]/**/*.{js,ts}",
9-
"cypress/integration/[filepath].{js,ts}",
8+
"[filepath]/**/*.{js,ts}",
9+
"[filepath].{js,ts}",
1010
"cypress/support/step_definitions/**/*.{js,ts}",
1111
]
1212
}
1313
```
1414

15-
This means that if you have a file `cypress/integration/duckduckgo.feature`, it will match step definitions found in
15+
This means that if you have a file `cypress/e2e/duckduckgo.feature`, it will match step definitions found in
1616

17-
* `cypress/integration/duckduckgo/steps.ts`
18-
* `cypress/integration/duckduckgo.ts`
17+
* `cypress/e2e/duckduckgo/steps.ts`
18+
* `cypress/e2e/duckduckgo.ts`
1919
* `cypress/support/step_definitions/duckduckgo.ts`
2020

2121
## Hierarchy
@@ -25,14 +25,14 @@ There's also a `[filepart]` option available. Given a configuration shown below
2525
```json
2626
{
2727
"stepDefinitions": [
28-
"cypress/integration/[filepart]/step_definitions/**/*.{js,ts}"
28+
"[filepart]/step_definitions/**/*.{js,ts}"
2929
]
3030
}
3131
```
3232

33-
... and a feature file `cypress/integration/foo/bar/baz.feature`, the preprocessor would look for step definitions in
33+
... and a feature file `cypress/e2e/foo/bar/baz.feature`, the preprocessor would look for step definitions in
3434

35-
* `cypress/integration/foo/bar/baz/step_definitions/**/*.{js,ts}`
36-
* `cypress/integration/foo/bar/step_definitions/**/*.{js,ts}`
37-
* `cypress/integration/foo/step_definitions/**/*.{js,ts}`
38-
* `cypress/integration/step_definitions/**/*.{js,ts}`
35+
* `cypress/e2e/foo/bar/baz/step_definitions/**/*.{js,ts}`
36+
* `cypress/e2e/foo/bar/step_definitions/**/*.{js,ts}`
37+
* `cypress/e2e/foo/step_definitions/**/*.{js,ts}`
38+
* `cypress/e2e/step_definitions/**/*.{js,ts}`

examples/browserify/cypress/plugins/index.ts renamed to examples/browserify/cypress.config.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { defineConfig } from "cypress";
12
import * as browserify from "@cypress/browserify-preprocessor";
23
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
34
import { preprocessor } from "@badeball/cypress-cucumber-preprocessor/browserify";
45

5-
export default async (
6+
export async function setupNodeEvents(
67
on: Cypress.PluginEvents,
78
config: Cypress.PluginConfigOptions
8-
): Promise<Cypress.PluginConfigOptions> => {
9+
): Promise<Cypress.PluginConfigOptions> {
910
await addCucumberPreprocessorPlugin(on, config);
1011

1112
on(
@@ -18,4 +19,12 @@ export default async (
1819

1920
// Make sure to return the config object as it might have been modified by the plugin.
2021
return config;
21-
};
22+
}
23+
24+
export default defineConfig({
25+
e2e: {
26+
specPattern: "**/*.feature",
27+
supportFile: false,
28+
setupNodeEvents,
29+
},
30+
});

examples/browserify/cypress.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/browserify/cypress/integration/duckduckgo.feature renamed to examples/browserify/cypress/e2e/duckduckgo.feature

File renamed without changes.
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import * as createBundler from "@bahmutov/cypress-esbuild-preprocessor";
1+
import { defineConfig } from "cypress";
2+
import createBundler from "@bahmutov/cypress-esbuild-preprocessor";
23
import { addCucumberPreprocessorPlugin } from "@badeball/cypress-cucumber-preprocessor";
34
import { createEsbuildPlugin } from "@badeball/cypress-cucumber-preprocessor/esbuild";
45

5-
export default async (
6+
export async function setupNodeEvents(
67
on: Cypress.PluginEvents,
78
config: Cypress.PluginConfigOptions
8-
): Promise<Cypress.PluginConfigOptions> => {
9+
): Promise<Cypress.PluginConfigOptions> {
910
await addCucumberPreprocessorPlugin(on, config);
1011

1112
on(
@@ -17,4 +18,12 @@ export default async (
1718

1819
// Make sure to return the config object as it might have been modified by the plugin.
1920
return config;
20-
};
21+
}
22+
23+
export default defineConfig({
24+
e2e: {
25+
specPattern: "**/*.feature",
26+
supportFile: false,
27+
setupNodeEvents,
28+
},
29+
});

0 commit comments

Comments
 (0)