[go: up one dir, main page]

@technote-space/clover-json
TypeScript icon, indicating that this package has built-in type declarations

0.4.40 • Public • Published

clover-json

npm version CI Status codecov CodeFactor License: MIT

Parse clover report files, and return a JSON representation in a lcov-parse compatible manner.

Table of Contents

Details

Usage

  1. Install
    • npm
      npm i @technote-space/clover-json
    • yarn
      yarn add @technote-space/clover-json
  2. Use
import { parseFile, parseContent } from "@technote-space/clover-json";

async function run(): Promise<void> {
    // Parse by file path
    const json1 = await parseFile('filepath.xml');

    // Parse by file contents
    const json2 = await parseContent('<?xml version="1.0" ?><coverage>...</coverage>');
}

run();

Sample Data

__tests__/assets/clover1.xml

[
  {
    "file": "coveralls/lib/client.js",
    "functions": {
      "details": [
        {
          "hit": 2,
          "line": 5,
          "name": "upload"
        }
      ],
      "found": 1,
      "hit": 1
    },
    "lines": {
      "details": [
        {
          "hit": 2,
          "line": 6
        },
        {
          "hit": 2,
          "line": 7
        },
        {
          "hit": 2,
          "line": 8
        },
        {
          "hit": 2,
          "line": 9
        }
      ],
      "found": 4,
      "hit": 4
    },
    "title": "Client"
  },
  {
    "file": "coveralls/lib/configuration.js",
    "functions": {
      "details": [
        {
          "hit": 4,
          "line": 6,
          "name": "fromEnvironment"
        }
      ],
      "found": 1,
      "hit": 1
    },
    "lines": {
      "details": [
        {
          "hit": 4,
          "line": 7
        },
        {
          "hit": 4,
          "line": 8
        },
        {
          "hit": 2,
          "line": 9
        },
        {
          "hit": 2,
          "line": 10
        },
        {
          "hit": 4,
          "line": 11
        },
        {
          "hit": 2,
          "line": 12
        },
        {
          "hit": 2,
          "line": 13
        },
        {
          "hit": 4,
          "line": 14
        },
        {
          "hit": 4,
          "line": 15
        }
      ],
      "found": 9,
      "hit": 9
    },
    "title": "Configuration"
  },
  {
    "file": "coveralls/lib/git_commit.js",
    "functions": {
      "details": [
        {
          "hit": 2,
          "line": 6,
          "name": "toJSON"
        }
      ],
      "found": 1,
      "hit": 1
    },
    "lines": {
      "details": [
        {
          "hit": 2,
          "line": 7
        },
        {
          "hit": 2,
          "line": 8
        },
        {
          "hit": 2,
          "line": 9
        },
        {
          "hit": 2,
          "line": 10
        },
        {
          "hit": 2,
          "line": 11
        },
        {
          "hit": 0,
          "line": 12
        },
        {
          "hit": 0,
          "line": 13
        },
        {
          "hit": 2,
          "line": 14
        },
        {
          "hit": 2,
          "line": 15
        }
      ],
      "found": 9,
      "hit": 7
    },
    "title": "GitCommit"
  }
]

Package Sidebar

Install

npm i @technote-space/clover-json

Weekly Downloads

186

Version

0.4.40

License

MIT

Unpacked Size

14.7 kB

Total Files

6

Last publish

Collaborators

  • technote