Tigraine

Daniel Hoelbling-Inzko talks about programming

Enable code coverage reports in create-react-app projects

Posted by Daniel Hölbling on January 15, 2017

create-react-app is a nice and easy way to bootstrap a new React.js project with some sane defaults and most of the tedious configuration required to enable Webpack building of Babeljs etc..

One thing I was missing from the generated configs though is how to output code coverage. Turns out it's rather simple - locate your package json and add the following line under scripts:

  {
    "coverage": "node scripts/test.js --env=jsdom --coverage"
  }

This way you can run yarn coverage or npm coverage and get a nicely formatted output with your coverage data. You can read more about the jest cli options in the docs

Filed under reactjs, testing, tools, javascript
comments powered by Disqus

My Photography business

Projects

dynamic css for .NET

Archives

more