I have added the reference of blanket. Once you execute bower install command, blanket.js will be downloaded to your lib folder. Now you need to add reference of blanket js and adapter for Jasmine to the HTML file. By default (if you’re using QUnit instead of Jasmine) you won’t require the adapter. You can add data-cover attribute to the source file, and when you’re executing tests, code coverage also will get captured. Since data-cover won’t work directly, you require Jasmine adapter, which is also comes along with the package. Here is the HTML.
The data-cover-only attribute used to specify the source files which you need to enable code coverage. And the data-cover-adapter attribute specifies the adapter for Jasmine. Now you can browse the html file and can view the code coverage results along with the test results. Here is the screenshot.
If you want to measure code coverage and fail the build if it fall less than specific value, you can use the following snippet. I have modified the run-jasmine.js file.
In this script, I am looking for the DIV with id blanket-main, which the container, with all the code coverage information. Inside that element I am looking for DIV with classes bl-cl and rs, which contains the coverage percentage. Here is the output from phantomjs.