Socket
Socket
Sign inDemoInstall

grunt-qunit-blanket-lcov

Package Overview
Dependencies
187
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grunt-qunit-blanket-lcov

Save LCOV reports generated by Blanket for Grunt QUnit.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
9.15 kB
Created
Weekly downloads
 

Readme

Source

grunt-qunit-blanket-lcov npm version

Save LCOV reports generated by Blanket for Grunt QUnit.

This is used to save Blanket.js tests coverage results done with grunt-contrib-qunit in order to send them to Coveralls.io with grunt-coveralls.

Getting Started

Setup the task

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-qunit-blanket-lcov --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-qunit-blanket-lcov');

Setup Blanket.js

Simply follow Blanket.js guide to setup the test coverage with QUnit. No special configuration of the test suite is needed.

Your test HTML should look like :

<!DOCTYPE html>
<html>
<head>
  <title>My test suite</title>
  <meta charset="utf-8">
  
  <link rel="stylesheet" href="../bower_components/qunit/qunit/qunit.css">
  
  <script src="../bower_components/jquery/dist/jquery.min.js"></script>
  <script src="../bower_components/qunit/qunit/qunit.js"></script>
  <script src="../bower_components/blanket/dist/qunit/blanket.min.js"></script>
  
  <script src="../src/library.js" data-cover></script>

  <script src="core.js"></script>
</head>

<body>
  <!-- -->
</body>
</html>

Don't forget to change the urls of the qunit task to add ?coverage=true for each test suite.

The "qunit_blanket_lcov" task

Overview

In your project's Gruntfile, add a section named qunit_blanket_lcov to the data object passed into grunt.initConfig().

grunt.initConfig({
  qunit_blanket_lcov: {
    lib: {
      src: 'src/library.js',
      options: {
        prefix: 'http://localhost:<%= connect.test.options.port %>/',
        dest: '.coverage-results/library.lcov'
      }
    }
  }
});

Then add or edit your test Grunt task to execute qunit_blanket_lcov before qunit.

grunt.registerTask('test', [
    'qunit_blanket_lcov',
    'qunit'
]);

Options

dest

Type: string Required

Output file for LCOV data.

prefix

Type: string Required

The prefix to remove from file paths, this is generally the host + port of the grunt-contrib-connect task you use.

force

Type: boolean Default value: false

By default the task will fail if there is no coverage results to write.

inject_reporter

Type: boolean Default value: true

Automatically insert the custom Blanket reporter in the PhantomJS instance. If you redefined the inject option of grunt-contrib-qunit you must set this option to false and manually add node_modules/grunt-qunit-blanket-lcov/reporter.js to the inject list.

Usage Examples

One file

In this example the test coverage results of library.js will be saved to library.lcov.

grunt.initConfig({
  qunit_blanket_lcov: {
    lib: {
      src: 'src/library.js',
      options: {
        prefix: 'http://localhost:9001/',
        dest: '.coverage-results/library.lcov'
      }
    }
  }
});
Multiple files

If you have many source files used by QUnit analyzed by Blanket it might be a good idea to use the Grunt files globbing option.

grunt.initConfig({
  qunit_blanket_lcov: {
    all: {
      files: [{
        expand: true,
        src: ['src/*.js', 'src/plugins/**/plugin.js']
      }],
      options: {
        prefix: 'http://localhost:9001/',
        dest: '.coverage-results/all.lcov'
      }
    }
  }
});

Keywords

FAQs

Last updated on 31 Mar 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc