Skip to content

Commit

Permalink
Merge pull request #1 from mmonfared/new_plugin
Browse files Browse the repository at this point in the history
update to use badeball plugin
  • Loading branch information
mmonfared authored Apr 16, 2023
2 parents 165f885 + 3c4bd31 commit 430b558
Show file tree
Hide file tree
Showing 5 changed files with 4,492 additions and 9,755 deletions.
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,34 @@ npx cypress open
### Install

```
npm install cypress-cucumber-preprocessor --save-dev
npm install @bahmutov/cypress-esbuild-preprocessor --save-dev
npm install @badeball/cypress-cucumber-preprocessor --save-dev
```

### add to config

`cypress.config.js`

```javascript
const cucumber = require('cypress-cucumber-preprocessor').default
const { defineConfig } = require("cypress");
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('file:preprocessor', cucumber())
on("file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin.default(config)],
}));
preprocessor.addCucumberPreprocessorPlugin(on, config);
return config;
},
specPattern: '**/features/*.{feature,features}',
excludeSpecPattern: '**/pages/*',
specPattern: "**/*.feature",
},
})
});

```

### configure the cypress-cucumber-preprocessor to using global step definitions
Expand Down Expand Up @@ -146,7 +155,7 @@ class TodoPage {
`cypress/support/step_definitions/steps.js`

```javascript
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'

import TodoPage from '../../e2e/pages/todoPage/todoPage'

Expand Down Expand Up @@ -277,7 +286,6 @@ npm install cypress-mochawesome-reporter --save-dev
`cypress.config.js`

```javascript
const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = defineConfig({
e2e: {
Expand Down
17 changes: 13 additions & 4 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
const cucumber = require('cypress-cucumber-preprocessor').default

const { defineConfig } = require("cypress");
const createBundler = require("@bahmutov/cypress-esbuild-preprocessor");
const preprocessor = require("@badeball/cypress-cucumber-preprocessor");
const createEsbuildPlugin = require("@badeball/cypress-cucumber-preprocessor/esbuild");

module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('file:preprocessor', cucumber()),
on(
"file:preprocessor",
createBundler({
plugins: [createEsbuildPlugin.default(config)],
})
);
preprocessor.addCucumberPreprocessorPlugin(on, config);
require('cypress-mochawesome-reporter/plugin')(on);
// Make sure to return the config object as it might have been modified by the plugin.
return config;
},
specPattern: '**/features/*.{feature,features}',
specPattern: '**/*.feature',
excludeSpecPattern: '**/pages/*',
videosFolder: "cypress/reports/videos",
screenshotsFolder: "cypress/reports/screenshots",
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/step_definitions/steps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'

import TodoPage from '../../e2e/pages/todoPage/todoPage'

Expand Down
Loading

0 comments on commit 430b558

Please sign in to comment.