Setting up cloud coverage statistics

 

It is very useful to track coverage status changes after commits:

  • It reveals risky changes early
  • It gives a clear warning to go ahead and fix it before it gets out of hand

For this example, we will use a free service called Coveralls:

$ npm install react react-dom --save$ npm install coveralls jest next react-test-renderer --save-dev

Same as before; we need to configure Babel too:

// .babelrc{  "env": {    "test": {      "presets": [        [          "env",          {            "modules": "commonjs"          }        ],        "next/babel"      ]    },    "development": {      "presets": [        "next/babel"      ]    }  }}

Let's configure Jest to collect coverage for us:

// jest.config.jsmodule.exports = {    testPathIgnorePatterns: [        './.idea',        './.next',        './node_modules'    ], collectCoverage: true, ...

Get Next.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.