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

playwright-to-istanbul

v1.0.2

Published

convert from playwright's coverage output to a format that can be used by istanbul reports

Downloads

738

Readme

Playwright to Istanbul

Node.js CI Coverage Status Standard Version

This is a fork of istanbuljs/puppeteer-to-istanbul, if you are using puppeteer, i would suggest using original library. it has been modified and added a function to manually passing a page to a function and setting the coverage.

Convert coverage from the format outputted by Playwright to a format consumable by Istanbul.

Usage

To Output Coverage in Istanbul Format with Playwright

  1. install playwright, npm init playwright@latest.

  2. install playwright-to-istanbul, npm i -D playwright-to-istanbul.

  3. run your code in playwright with coverage enabled:

    (async () => {
      const pti = require('playwright-to-istanbul')
      const { chromium } = require('playwright');
      const browser = await chromium.launch()
      const page = await browser.newPage()
    
      // Enable both JavaScript and CSS coverage
      await Promise.all([
        page.coverage.startJSCoverage(),
        page.coverage.startCSSCoverage()
      ]);
      // Navigate to page
      await page.goto('https://www.google.com');
      // Disable both JavaScript and CSS coverage
      const [jsCoverage, cssCoverage] = await Promise.all([
        page.coverage.stopJSCoverage(),
        page.coverage.stopCSSCoverage(),
      ]);
      pti.write([...jsCoverage, ...cssCoverage], { includeHostname: true , storagePath: './.nyc_output' })
      await browser.close()
    })()

To Check Istanbul Reports

  1. install nyc, npm i nyc -g.

  2. use nyc's report functionality:

    nyc report --reporter=html

playwright-to-istanbul outputs temporary files in a format that can be consumed by nyc.

see istanbul for a list of possible reporters.

Contributing

The best way to get started with Playwright to Istanbul is by installing it for yourself and running tests. PTI requires the most recent build of v8toistanbul to function properly, so start by running npm install.

Next, ensure that all tests are passing before continuing by running npm test (or equivalently, npm t). This should generate a report that gives the same coverage as seen on this README.

Note that a majority of the tests run against pre-generated fixtures, or JSON snippets, that come from Playwright's raw output. These are located in the \test\fixtures area. To generate one of your own, write or use one of the scripts in the test area test\sample_js, and run bin/puppeteer-js-runner.js through node, like so:

node bin/puppeteer-js-runner.js --file=/test/sample_js/sample2.js.

If you see an issue with Playwright to Istanbul, please open an issue! If you want to help improve Playwright to Istanbul, please fork the repository and open a pull request with your changes.

Make sure to review our contributing guide for specific guidelines on contributing.