Socket
Book a DemoInstallSign in
Socket

istanbul-jpm

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

istanbul-jpm

An istanbul Instrumenter for use with JPM

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

istanbul-jpm

Istanbul Instrumenter and coverage export for Firefox Add-on SDK extensions tested with JPM.

Installation

Run npm install --save-dev istanbul-jpm in the root of your extension directory.

Usage

The index of this module exports the Instrumenter from istanbul adapted for use with JPM. It does so by storing the coverage variable in a special object, that gets written to the disk after all tests are done. This means, that this module has to be packaged into the XPI file when running jpm test to measure coverage. Note that istanbul doesn't need to be packaged with it.

var Instrumenter = require("istanbul-jpm").Instrumenter;

The "global" that the Instrumenter wrote to can be accessed in node like this:

const g = require("istanbul-jpm/global-node").global;

The module reads the data from the disk and returns it in object form on the "global" property.

You might want to set the directory used to pass the coverage information from the extension back to node using the environment variable coveragedir. By default, it will use node's and Firefox's idea of the system's temp directory. It is known that those do not match up on Max OS X.

Example usage with grunt-istanbul

Also uses grunt-shell to launch jpm test.

module.exports = function(grunt) {
    var istanbulJpm = require("istanbul-jpm");

    // Make sure Firefox writes the coverage info to the same dir we'll read from.
    process.env.coveragedir = require("os").tmpdir();

    grunt.initConfig({
        shell: {
            jpmTest: {
                command: 'jpm test'
            }
        },
        instrument: {
            files: 'lib/**/*.js',
            options: {
                lazy: true,
                basePath: 'coverage/instrument/',
                instrumenter: istanbulJpm.Instrumenter
            }
        },
        storeCoverage: {
            options: {
                dir: 'coverage/reports'
            }
        },
        makeReport: {
            src: 'coverage/reports/**/*.json',
            options: {
                type: 'lcov',
                dir: 'coverage/reports',
                print: 'detail'
            }
        }
    });

    grunt.loadNpmTasks('grunt-shell');
    grunt.loadNpmTasks('grunt-istanbul');

    grunt.registerTask('readcoverageglobal', 'Reads the coverage global JPM wrote', function() {
        global.__coverage__ = require("istanbul-jpm/global-node").global.__coverage__;
        grunt.log.ok("Read __coverage__ global");
    });

    grunt.registerTask('test', ['instrument', 'shell:jpmTest', 'readcoverageglobal', 'storeCoverage', 'makeReport']);
};

Keywords

jetpack

FAQs

Package last updated on 12 May 2016

Did you know?

Socket

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