Code Monkey home page Code Monkey logo

mocha-lcov-reporter's Introduction

mocha-lcov-reporter

LCOV reporter for Mocha.

LCOV format can be found in this geninfo manpage. This LCOV reporter was built after Sonar Javascript Plugin LCOVParser class.

Usage

The mocha-lcov-reporter is a reporter for mocha. In order to get coverage data, the same instructions are to be followed as for the JSONCov and HTMLCov reporters:

  • Install node-jscoverage
  • Instrument your library with node-jscoverage
  • Run your tests against your instrumented libraray and save the output

For example, the following script can be part of your build process:

#!/usr/bin/env bash
rm -rf coverage
rm -rf lib-cov

mkdir coverage

node-jscoverage lib lib-cov
mv lib lib-orig
mv lib-cov lib
mocha -R mocha-lcov-reporter > coverage/coverage.lcov
rm -rf lib
mv lib-orig lib

This script instruments your library (library 'lib', target 'lib-cov'), temporarily replaces your library by the instrumented version, run the tests and undo the replacing of the original library by the instrumented library.

A safer and better approach is to coverage your library, and include the directory with the instrumented code from your tests directly. Instead of doing a 'require("../lib")' do a 'require("../lib-cov")'. This saves the hassle of replacing directory 'lib' with directory 'lib-cov' and undoing it afterwards. You can set an environment variable to check if the instrumented library should be included or the normal version:

var lib = process.env.JSCOV ? require('../lib-cov') : require('../lib');

And run mocha as follows:

JSCOV=1 mocha -R mocha-lcov-reporter > coverage/coverage.lcov

mocha-lcov-reporter's People

Contributors

stevenlooman avatar

Watchers

Michael Weibel avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.