A Cypress coverage plugin for monocart coverage reports
npm i cypress-monocart-coverage
- Cypress 13+
- V8 Coverage Only
- Supported Browsers
- chrome
- chromium
- edge
- add support
// cypress/support/e2e.js
import 'cypress-monocart-coverage/support';
- add plugin
// cypress.config.js
const { defineConfig } = require('cypress');
const CypressCoveragePlugin = require('cypress-monocart-coverage');
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
CypressCoveragePlugin(on, config, {
name: 'My Cypress e2e Coverage Report',
entryFilter: {
'**/*.cy.js': true
},
outputDir: './coverage-reports/e2e',
reports: [
'v8',
'console-details',
'raw'
]
});
}
}
});
- add support
// cypress/support/component.js
import 'cypress-monocart-coverage/support';
- add plugin
// cypress.config.js
const { defineConfig } = require('cypress');
const CypressCoveragePlugin = require('cypress-monocart-coverage');
module.exports = defineConfig({
component: {
setupNodeEvents(on, config) {
CypressCoveragePlugin(on, config, {
name: 'My Cypress component Coverage Report',
entryFilter: {
'**/src/spec*.js': true
},
sourceFilter: {
'**/cypress/component/**': true
},
outputDir: './coverage-reports/component',
reports: [
'v8',
'console-details',
'raw'
]
});
},
devServer: {
framework: 'react',
bundler: 'webpack'
}
}
});
"scripts": {
"test": "npm run test:e2e && npm run test:component && npm run merge",
"test:e2e": "npx cypress run --browser edge",
"test:component": "npx cypress run --component --browser edge",
"merge": "node ./merge-coverage.js"
}
- See example merge-coverage.js
- See example cypress.config.js
- Check monocart coverage reports for more coverage options.