Cypress — code coverage reports for unit tests

One of most common test reports used is code coverage reports. And while Cypress does support them, setting them up can be a bit of pain. In this post, I will be explaining how to set up coverage reports for unit test. If you haven’t installed Cypress yet, you can use my previous post as a guide on that.

Cypress logo
  • babel-plugin-transform-class-properties
  • instanbul-lib-coverage
  • mocha@⁵.2.0
  • nyc
npm install — save-de @cypress/code-coverage babel-plugin-transform-class-properties instanbul-lib-coverage mocha@⁵.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};
cypress run --spec cypress/integration/unit/*