Skip to content
given coverage information output by puppeteer's API output a format consumable by Istanbul reports
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin feat: add command-line-tool for outputting coverage in puppeteer form… Feb 24, 2018
lib feat: add support for complete path reporting on files with http(s) p… Aug 11, 2018
test feat: add support for complete path reporting on files with http(s) p… Aug 11, 2018
.gitignore
.travis.yml chore: add CI (#2) Feb 24, 2018
CHANGELOG.md
CONTIRUBTORS.md Updated CONTRIBUTORS Feb 25, 2018
CONTRIBUTING.md
LICENSE.txt Added ISC License Feb 25, 2018
README.md chore: Update README for contributor first steps (#14) Mar 16, 2018
index.js
package.json chore(release): 1.2.2 Mar 3, 2018

README.md

Puppeteer to Istanbul

Build Status Coverage Status Standard Version

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

Usage

To Output Coverage in Istanbul Format with Puppeteer

  1. install puppeteer, npm i puppeteer --save.

  2. install puppeteer-to-istanbul, npm i puppeteer-to-istanbul --save.

  3. run your code in puppeteer with coverage enabled:

    (async () => {
      const pti = require('puppeteer-to-istanbul')
      const puppeteer = require('puppeteer')
      const browser = await puppeteer.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)
      await browser.close()
    })()

To Run Istanbul Reports

  1. install nyc, npm i nyc -g.

  2. use nyc's report functionality:

    nyc report --reporter=html

puppeteer-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 Puppeteer 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 Puppeteer'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 Puppeteer to Istanbul, please open an issue! If you want to help improve Puppeteer 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.

You can’t perform that action at this time.