npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@connectis/coverage-parser

v1.0.8

Published

Library for parsing coverage reports.

Downloads

19,517

Readme

coverage-parser

A Node.js library for parsing coverage reports.

NPM versionDependency Status

This library bundles different coverage parsers that parse coverage information in a uniform way. Supported coverage report formats:

Note: if you want to merge the parsed results you can use @connectis/coverage-merger.

Example

const coverageParser = require('@connectis/coverage-parser');

coverageParser
    .parseGlobs('**/lcov.info', {
        type: 'lcov'
    })
    .then(results => console.log(results));

API

The API includes the following:

  • parseGlobs(globs, options)
  • parseFiles(files, options)
  • parseFile(file, options)
  • types

types

Type Array<string>

Array of available parser types.

options

Type object

options.type

Type: string

The type of parser which should be used for parsing the coverage files. See the exported types array for available types.

options.parser

Type: function

Custom parser function for parsing the coverage files: (file) => Promise<Array<CoverageResult>>. See below.

options.pathMode

Type: 'absolute' | 'relative' | 'unmodified'

Default: 'absolute'

The type of paths that should be used in the parsed result. See options.baseDir.

options.baseDir

Type: string

Default: process.cwd()

The base directory that will be used for making paths relative or absolute in the coverage reports. See options.pathMode.

parseGlobs(globs, options)

Finds all coverage reports matching the glob patterns and parses the results.

globs

Type: Array<string>|string

Either an of glob patterns or a single glob pattern.

options

Type: options. See above.

options.globOptions

Type: object

Options to pass to fast-glob.

returns

Type: Promise<Array<CoverageResult>>. See below.

parseFiles(files, options)

Parses all coverage reports files.

files

Type: Array<string>

An array of file paths.

options

Type: options. See above.

returns

Type: Promise<Array<CoverageResult>>. See below.

parseFile(file, options)

Parses the coverage reports file.

file

Type: string

The file path.

options

Type: options. See above.

returns

Type: Promise<Array<CoverageResult>>. See below.

CoverageResult

The returned data has the following format.

{
  "title": "Test #1",
  "file": "/some/absolute/path/anim-base/anim-base-coverage.js",
  "functions": {
    "hit": 23,
    "found": 29,
    "details": [
      {
        "name": "(anonymous 1)",
        "line": 7,
        "hit": 6
      },
      {
        "name": "(anonymous 2)",
        "line": 620,
        "hit": 225
      },
      {
        "name": "_end",
        "line": 516,
        "hit": 228
      }
    ]
  },
  "lines": {
    "found": 181,
    "hit": 143,
    "details": [
      {
        "line": 7,
        "hit": 6
      },
      {
        "line": 29,
        "hit": 6
      },
      {
        "line": 41,
        "hit": 0
      }
    ]
  },
  "branches": {
    "found": 2,
    "hit": 1,
    "details": [
      {
        "line": 9,
        "branch": 0,
        "taken": 0
      },
      {
        "line": 9,
        "branch": 1,
        "taken": 1
      }
    ]
  }
}