Step 1: Installation
i. Install mocha
npm install mocha --save-dev
ii. Install cypress-multi-reporters
npm install cypress-multi-reporters --save-dev
iii. Install mochawesome
npm install mochawesome --save-dev
iv. Install mochawesome-merge
npm install mochawesome-merge --save-dev
v. Install mochawesome-report-generator
npm install mochawesome-report-generator --save-dev
Step 2: Add reporter settings in cypress.json
"reporter": "cypress-multi-reporters",
"reporterOptions": {
"reporterEnabled": "mochawesome",
"mochawesomeReporterOptions": {
"reportDir": "cypress/reports/mocha",
"quite": true,
"overwrite": false,
"html": false,
"json": true
}
}
}
Step 3: Add scripts in package.json file
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "cypress open",
"clean:reports": "rmdir /S /Q cypress\\reports && mkdir
cypress\\reports && mkdir cypress\\reports\\mochareports",
"pretest": "npm run clean:reports",
"scripts": "cypress run",
"combine-reports": "mochawesome-merge
cypress/reports/mocha/*.json > cypress/reports/mochareports/report.json",
"generate-report": "marge cypress/reports/mochareports/report.json
-f report -o cypress/reports/mochareports",
-f report -o cypress/reports/mochareports",
"posttest": "npm run combine-reports && npm run generate-report",
"test1": "npm run scripts || npm run posttest"
},
Step 4: Run testcase
Step 4: Run testcase
npm run test1
Report in:
Cypress/Reports/Mochareports/report.html
0 Comments:
Đăng nhận xét