Adding code coverage checking

Kent C. Dodds
InstructorKent C. Dodds

Share this video with your friends

Send Tweet

Now that we have code coverage being reported, let's make sure that nobody commits code which drops code coverage below our standard by adding a check-coverage script that utilizes istanbul's built-in check-coverage command.

janppires
janppires
~ 5 years ago

Hi Kent!

How can we integrate this coverage checking with webpack?

I have been searching but I haven't found anything. =(

Thanks!

janppires
janppires
~ 5 years ago

I got the answer myself.

In an webpack usage, we still need to install "istanbul" dependency, just to run the command "istanbul check-coverage build/reports/web-coverage/coverage-final.json --statements 100 --branches 100 --functions 100 --lines 100" agains the "coverage-final.json" produced by karma-coverage. So it's important to have reporter type as "json" in the reporters array of coverageReporter karma.config file.

coverageReporter : {
          dir: 'build/reports/web-coverage',
          reporters: [
              {type: 'json', subdir: '.'},
          ]
      },

Cheers