Coder Social home page Coder Social logo

v8-to-istanbul's Introduction

v8-to-istanbul

Build Status Conventional Commits nycrc config on GitHub

converts from v8 coverage format to istanbul's coverage format.

Usage

const v8toIstanbul = require('v8-to-istanbul')
// the path to the original source-file is required, as its contents are
// used during the conversion algorithm.
const converter = v8toIstanbul('./path-to-instrumented-file.js')
await converter.load() // this is required due to the async source-map dependency.
// provide an array of coverage information in v8 format.
converter.applyCoverage([
  {
    "functionName": "",
    "ranges": [
      {
        "startOffset": 0,
        "endOffset": 520,
        "count": 1
      }
    ],
    "isBlockCoverage": true
  },
  // ...
])
// output coverage information in a form that can
// be consumed by Istanbul.
console.info(JSON.stringify(converter.toIstanbul()))

// cleanup resources allocated in "load" (i.e. by the source-map dependency),
// the converter may not be used anymore afterwards
converter.destroy() 

Ignoring Uncovered Lines

Sometimes you might find yourself wanting to ignore uncovered lines in your application (for example, perhaps you run your tests in Linux, but there's code that only executes on Windows).

To ignore lines, use the special comment /* c8 ignore next */.

ignoring the next line

const myVariable = 99
/* c8 ignore next */
if (process.platform === 'win32') console.info('hello world')

ignoring the next N lines

const myVariable = 99
/* c8 ignore next 3 */
if (process.platform === 'win32') {
  console.info('hello world')
}

ignoring all lines until told

/* c8 ignore start */
function dontMindMe() {
  // ...
}
/* c8 ignore stop */

ignoring the same line as the comment

const myVariable = 99
const os = process.platform === 'darwin' ? 'OSXy' /* c8 ignore next */ : 'Windowsy' 

Testing

To execute tests, simply run:

npm test

v8-to-istanbul's People

Contributors

bcoe avatar renovate[bot] avatar github-actions[bot] avatar release-please[bot] avatar simenb avatar dependabot[bot] avatar j03m avatar shinnn avatar ssams avatar bvanjoi avatar sjoerdvisscher avatar molow avatar viceice avatar jakxz avatar hugomrdias avatar glromeo avatar connorjclark avatar clemyan avatar

Watchers

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.