Insturments buffers and generates lcov compatible data from collected results to generate coverage reports.


The prupose of this module is to provide helpers for node.js for instrumenting and generating lcov style reports.


instrument(buffer, "filename")

  • bufferhas to contain the code that you want to instrument.
  • filenamecan be any string and will be used for the reporting.
  • The return value is a bufferwith the instrumented code

Executing the instrumented code will create and fill an object called _$Coverage. The contents will look like this:

    filename: {
        linenumber: timesExecuted


var _$Coverage = {
    'someJsFile.js': {
        0: 1,
        2: 1,
        5: 3,
        7: 0


  • exectuedLinesis normaly just _$Coveragebut you can pass anything that follows it's format.

  • The return value is a stringthat follows the LCOV Data style. The output will look like this:

    SF:someJsFile DA:0,1 DA:2,1 DA:5,3 DA:7,0 end_of_record

You can visualize this by saving this to a file and running lcov -l coverage.datalso genhtml coverage.dat -o /tmp/reportwill be your friend.

combineResults(executedLines[, executedLines, …])

  • exectuedLinesis normaly just _$Coveragebut you can pass anything that follows it's format.
  • You can pass as many executedLinesas you want to combine for example multiple clients.
  • The return value is an objectin the same format as _$Coveragebut with all runs added up






  • 从零搭建自己的js工具库 typescript+rollup+karma+mocha+coverage

    前言 随着公司产品线的增多,开发维护的项目也越来越多,在业务开发过程中,就会发现经常用到的cookie处理,数组处理,节流防抖函数等工具函数,这些工具函数在很多的项目中会使用到,为了避免一份代码多...

    7 个月前
  • ze-helpers

    zeRusski little helpers zeHelpers zeRusski's little helpers Sample output looks like this: js...

    9 个月前
  • yuitest-coverage

    Node.js wrapper for yuitestcoverage java package YUI Test Coverage Node.js Module =================...

    8 个月前
  • web3-core-helpers

    Web3 core tools helper for sub packages. This is an internal package. web3corehelpers This is a s...

    1 年前
  • vue-runtime-helpers

    Runtime helpers for Vue SFC. vueruntimehelpers Reusable helpers to inject styles and normalize co...

    1 年前
  • verb-repo-helpers

    Commonly used helpers for adding repositoryrelated data to templates in verb projects. verbrepohel...

    2 年前
  • unit-coverage

    unitcoverage Build Status(

    1 年前
  • type-coverage

    A CLI tool to check type coverage for typescript code typecoverage Docs: Repository https://...

    2 个月前
  • ts-helpers

    Typescript helpers for compiling typescript while specifying within your . Cross platform ( Node/Br...

    1 年前
  • template-helpers

    Generic JavaScript helpers that can be used with any template engine. Handlebars, LoDash, Underscore...

    1 年前


扫码加入 JavaScript 社区