I am working on Cypress BBD Framework using cucumber:
The following are dependencies installed:
"devDependencies": {
"cypress": "^13.11.0",
"cypress-cucumber-preprocessor": "^4.3.1"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": false,
"stepDefinitions": "cypress/e2e/Cucumber/tests/"
}
My Current Folder Structure:
.
└── CypressCucumberFramework-Version1/
├── cypress/
│ ├── e2e/
│ │ └── Cucumber/
│ │ ├── features/
│ │ │ ├── flightReservation.feature
│ │ │ ├── registerPage.feature
│ │ │ └── signOn.feature
│ │ ├── pages/
│ │ │ ├── flightReservation.js
│ │ │ ├── registerPage.js
│ │ │ └── signOn.js
│ │ └── tests/
│ │ ├── testFlightReservation.cy.js
│ │ ├── testRegisterPage.cy.js
│ │ └── testSignOnPage.cy.js
│ ├── fixtures/
│ │ └── testData.json
│ ├── support/
│ │ ├── commands.js
│ │ └── e2e.js
│ ├── screenshots
│ └── videos
├── node_modules
├── cypress.config.js
├── package-lock.json
└── package.json
I am able to successfully execute the tests from Cypress Test Runner and VScode Terminal when Allure Cypress Reporting dependencies are not installed.
So, when I add the Allure Cypress Reporting dependencies below"
package.json
"devDependencies": {
"allure-commandline": "^2.29.0",
"allure-cypress": "^3.0.0-beta.3",
"cypress": "^13.11.0",
"cypress-cucumber-preprocessor": "^4.3.1"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": false,
"stepDefinitions": "cypress/e2e/Cucumber/tests/"
}
cypress.config.js
const { defineConfig } = require("cypress");
const cucumber = require('cypress-cucumber-preprocessor').default
const { allureCypress } = require("allure-cypress/reporter");
module.exports = defineConfig({
video:true,
screenshotOnRunFailure: true,
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
//Cucumber PreProcessor
on('file:preprocessor', cucumber())
//Allure Reports
allureCypress(on);
},
specPattern: "cypress/e2e/Cucumber/features/*.feature"
},
env:{
registerPageURL:'https://demo.guru99.com/test/newtours/register.php',
signOnPageURL:'https://demo.guru99.com/test/newtours/login.php',
flightReservation: 'https://demo.guru99.com/test/newtours/reservation.php',
}
});
e2e.js
// Import commands.js using ES2015 syntax:
import './commands';
import "allure-cypress/commands";
So, while executing the tests with above mentioned configurations and dependencies for Allure Cypress Reporting i am facing the below issues:
Referance: https://allurereport.org/docs/cypress/
Error:
The error was:
Error: Can't walk dependency graph: Cannot find module 'allure-cypress/commands' from 'C:\Users\angshumanbasak\CypressCucumberFramework-Version1\cypress\support\e2e.js'
required by C:\Users\angshumanbasak\CypressCucumberFramework-Version1\cypress\support\e2e.js
at C:\Users\angshumanbasak\CypressCucumberFramework-Version1\node_modules\resolve\lib\async.js:146:35
at processDirs (C:\Users\angshumanbasak\CypressCucumberFramework-Version1\node_modules\resolve\lib\async.js:299:39)
at isdir (C:\Users\angshumanbasak\CypressCucumberFramework-Version1\node_modules\resolve\lib\async.js:306:32)
at C:\Users\angshumanbasak\CypressCucumberFramework-Version1\node_modules\resolve\lib\async.js:34:69
at callback (C:\Users\angshumanbasak\AppData\Local\Cypress\Cache\13.11.0\Cypress\resources\app\node_modules\@packages\server\node_modules\graceful-fs\polyfills.js:299:20)
at callback (C:\Users\angshumanbasak\AppData\Local\Cypress\Cache\13.11.0\Cypress\resources\app\node_modules\@packages\server\node_modules\graceful-fs\polyfills.js:299:20)
at FSReqCallback.oncomplete (node:fs:197:21)
This occurred while Cypress was compiling and bundling your test code. This is usually caused by:
- A missing file or dependency
- A syntax error in the file or one of its dependencies
Fix the error in your code and re-run your tests.
While I have the import "allure-cypress/commands"; in e2e.js I am not able to comprehend why I am facing this module dependency error. Any help to resolve the issue will really be appreciated !
In the beta.3 version, there is no allure-cypress/commands
folder, look under the node-modules/allure-cypress
folder - there is only /dist
folder.
So remove the line import "allure-cypress/commands"
. If you have gotten this from some old notes and wish to follow them, downgrade to v.2.15.1
.