npm install --save-dev cypress
Headed
cypress open
Headless
cypress run
--browser
cypress run --browser chrome
--headless
cypress run --headless
--spec
cypress run --spec folder/test.spec.js
--config-file
cypress run --config-file test/cypress.json
Required packages
- mocha
- mochawesome
npm install mocha@^5.0.0
npm install mochawesome
cypress run --reporter mochawesome
Adding reporter
{
"reporter": "mochawesome"
}
Reporter options
{
"reporter": "mochawesome",
"reporterOptions": {
"charts": true,
"html": true,
"json": true,
"reportDir": "cypress/reports",
"reportFilename": "report"
}
}
Issues:
- requires mocha version ^5.0.0, with 6+ won't work
- generates report per test suite
npm install mochawesome-merge --save-dev
{
"reporter": "mochawesome",
"reporterOptions": {
"charts": true,
"overwrite": false,
"html": false,
"json": true,
"reportDir": "cypress/report/mochawesome-report"
}
}
mochawesome-merge cypress/report/mochawesome-report/*.json > cypress/report/output.json
marge cypress/report/output.json --reportDir ./ --inline
const fs = require("fs");
fs.rmdirSync("./cypress/reports", {recursive: true});
npm install --save-de @cypress/code-coverage babel-plugin-transform-class-properties instanbul-lib-coverage mocha@^5.2.0 nyc
{
"presets": ["@babel/preset-react"],
"plugins": ["transform-class-properties", "istanbul"]
}
import '@cypress/code-coverage/support'
module.exports = (on, config) => {
on('task', require('@cypress/code-coverage/task'));
on('file:preprocessor', require('@cypress/code-coverage/use-babelrc'));
return config;
}