Coder Social home page Coder Social logo

coverage-viewer's Introduction

Coverage Viewer

npm version Build Status Coverage

Turn your code coverage output into a website for exploring your project's coverage statistics more easily:

Installation

npm i -g coverage-viewer

Usage

Currently only tested with C# coverlet JSON output.

CLI Usage:

Usage: coverage-viewer <coverageFile> [options]

Options:
  -s             The root of your project's source code directory     [required]
  -o             Where coverage-viewer should write output
  -u, --up       Whether to start the express viewing server           [boolean]
  -v, --version  Show version number                                   [boolean]
  -h, --help     Show help                                             [boolean]

Examples:
  coverage-viewer coverage.json -s ./src -o ./coverage

Using the -u or --up flags, you can run an express app to view the output, and automatically re-run the generator if the coverage file changes.

coverage-viewer coverage.json -s ./src -o ./coverage --up

Alternatively, once you've generated the output, serve it with your preferred server:

npm i -g httpserver
cd coverage
httpserver

License

MIT © Forrest Desjardins

coverage-viewer's People

Contributors

coderpatros avatar dependabot[bot] avatar fdesjardins avatar rowan-bulkow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

coverage-viewer's Issues

Add option to group files by directory

Especially for larger projects, instead of seeing a huge list of files on the summary page, it'd be nice to offer a way to group them into directories.

Cannot generate coverage report with output from Coverlet 2.5.1

Using the current most recent version of coverlet (via coverlet.msbuild NuGet package version 2.5.1) and coverage-viewer (version 0.3.0), an error is thrown when generating the coverage report:

/Users/lyleshearer/.npm/_npx/78321/lib/node_modules/coverage-viewer/lib/statistics.js:22
    line => line.stats.find(stat => stat.name === 'Hits').value !== 0
                                                         ^

TypeError: Cannot read property 'value' of undefined

This can be repro'd by cloning and running this script on a fork of the coverlet repo.

This appears to be because the coverlet output format for coverage.json changed, perhaps when support for branch coverage was added. The format of the test asset is quite different than the one generated during that repro test.

Exception: TypeError: data.map(...).flat is not a function

Environment
coverage-viewer: 0.4.1
OS: Windows 10
shell: PowerShell
npm: 6.13.0
node: v10.16.3

Install output

> npm i -g coverage-viewer

npm WARN deprecated [email protected]: This method has been renamed to "flat" - please use `array.prototype.flat` instead
C:\Users\larry\AppData\Roaming\npm\coverage-viewer -> C:\Users\larry\AppData\Roaming\npm\node_modules\coverage-viewer\cli.js
+ [email protected]
added 108 packages from 65 contributors in 10.354s

Exception

> coverage-viewer "./tests/coverage.json" -s "./src" -o "./viewer"

C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\statistics.js:1
const getAllFiles = data => data.map(project => project.files).flat()
                                                               ^

TypeError: data.map(...).flat is not a function
    at getAllFiles (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\statistics.js:1:64)
    at exports.getFileStats.data (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\statistics.js:93:17)
    at renderFile (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:34:21)
    at files.map.file (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:52:13)
    at Array.map (<anonymous>)
    at Object.exports.renderFiles (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:49:16)
    at fs.readFile (C:\Users\me\AppData\Roaming\npm\node_modules\coverage-viewer\lib\render.js:73:13)
    at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)

Add option to serve the coverage report

It's kind of a hassle to have to generate the html over and over. You can use nodemon or similar to regenerate the reports when the coverage output changes, then run browsersync to get livereloading...

I think it'd be better to just serve the reports when the user passes a flag to save them the hassle.

Statistics.js issue

Hi! This tool looks awesome. Would love to use it.

Getting an error when I try to run it, wondering if it's due to array.prototype.flatten being deprecated, and is now 'array.prototype.flat' ?

npm WARN deprecated [email protected]: This method has been renamed to "flat" - please use `array.prototype.flat` instead

I run:
coverage-viewer coverage.json -s /Users/me/Documents/GitHub/MyProject/src -o ./coverage
and receive

/usr/local/lib/node_modules/coverage-viewer/lib/statistics.js:22
    line => line.stats.find(stat => stat.name === 'Hits').value !== 0

TypeError: Cannot read property 'value' of undefined
    at lines.filter.line (/usr/local/lib/node_modules/coverage-viewer/lib/statistics.js:22:58)
    at Array.filter (<anonymous>)
    at getLinesHit (/usr/local/lib/node_modules/coverage-viewer/lib/statistics.js:21:9)
    at exports.getLineStats.data (/usr/local/lib/node_modules/coverage-viewer/lib/statistics.js:39:20)
    at files.map.file (/usr/local/lib/node_modules/coverage-viewer/lib/statistics.js:100:18)
    at Array.map (<anonymous>)
    at exports.getFileStats.data (/usr/local/lib/node_modules/coverage-viewer/lib/statistics.js:97:16)
    at renderFile (/usr/local/lib/node_modules/coverage-viewer/lib/render.js:34:21)
    at files.map.file (/usr/local/lib/node_modules/coverage-viewer/lib/render.js:52:13)
    at Array.map (<anonymous>)

If it's not that, I'm probably doing something wrong. Do you have any suggestions?

Thanks so much

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.