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

@pgiletich/cypress-v8-coverage-plugin

v1.0.1

Published

Cypress V8 coverage chrome plugin

Downloads

2

Readme

Cypress V8 Coverage Plugin

this plugin aims at providing codecoverage using the chrome V8 coverage api

It is adapted from this poc

Abilities and limitation

This plugin does :

  • gather coverage on multiple tests
  • gather coverage on multiple files
  • works with chrome
  • converts coverage reports to html or lcov
  • apply sourcemaps on a report generation

This plugins doesn't

  • handle other browser than chrome ( for technical limitation reasons )
  • cure all afflictions, make children behave, or long lost loves come back, this is not black magic 🧙‍♀️.

Usage

Configuration:

required

    {...
        "env":{
            "v8_coverage":{
                "include":["glob/**/to/your/files.*js","other/glob"],
                "src_root":"path/to/your/src/root",
                "collect_coverage_timeout":120000 //optional, this affects the final code collection step, that may timeout if your codebase is big enough
            }
        }
    }

On coverage collection we will replace the url root with the supplied src_root, and run the glob matching on the result string

Both thoses settings are required as they are used to recognize which files are to be kept amongst all the browser loaded files.

support/index.js

[...]
import "cypress_v8_coverage_plugin/support"
[...]

This allows the plugin to hook on test lifecyle events

plugins/indes.js

const cypress_v8_plugin = require("cypress_v8_coverage_plugin/plugin")
module.exports = (on, config) => {
    ...
    config = cypress_v8_plugin(on,config)
    ...
    return config
}

This registers the plugin in to cypress

Optional Collect

optional

At the end of each spec a collection spec occurs, gathering coverage data from the spec's tests. This can be a lengthy process, to reduce the run cost, you can add the skip_coverage_collection option :

    {...
        "env":{
            "v8_coverage":{
                ...,
                skip_coverage_collection:true
                ...
            }
        }
    }

And run independently the src/scripts/collectCoverage.js script to collect coverage and convert it to istanbul, while applying the sourcemap

Convertion

optional You can trigger a report convertion to the html or lcov through the convert_coverage task

This run the nyc command through npx on the generated files.

afterAll(()=>{
    cy.task("convertCoverage",'html',"./html/report/dir")//use an empty dir, this generates a lot of files
    cy.task("convertCoverage","lcov","./lcovpath.info")
})

Otherwise, you can trigger this convertion manualy using nyc or istanbul