How to do it...

Create a new directory and place a file named package.json in it. Inside it, write the following:

{ "name": "learning-code-coverage", "version": "1.0.0"}

This creates an npm project. In the same directory, run the following command to install our dependencies:

npm install vue karma karma jasmine karma-jasmine karma-coverage karma-chrome-launcher --save-dev

The package.json file changes accordingly.

The karma-coverage plugin uses the underlying software, Istanbul, to measure and display the coverage of our tests.

To make the next step a little easier, we will install Karma globally (if you have not already done it). Run the following command:

npm install -g karma

When Karma is installed, run the following command in your ...

Get Vue.js 2 Cookbook 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.