• Stars
    star
    209
  • Rank 181,582 (Top 4 %)
  • Language
    JavaScript
  • License
    ISC License
  • Created about 6 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

given coverage information output by puppeteer's API output a format consumable by Istanbul reports

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 -D puppeteer.

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

  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, ...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

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.

More Repositories

1

nyc

the Istanbul command line interface
JavaScript
5,522
star
2

istanbuljs

monorepo containing the various nuts and bolts that facilitate istanbul.js test instrumentation
JavaScript
970
star
3

babel-plugin-istanbul

A babel plugin that adds istanbul instrumentation to ES6 code
JavaScript
612
star
4

v8-to-istanbul

convert from v8 coverage format to istanbul's format
JavaScript
101
star
5

spawn-wrap

Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.
JavaScript
36
star
6

istanbuljs.github.io

the Istanbul community website
JavaScript
23
star
7

append-transform

handle multiple require hooks
JavaScript
21
star
8

caching-transform

Wraps a transform and provides caching
JavaScript
20
star
9

eslint-plugin-istanbul

ESLint plugin for istanbul code coverage
JavaScript
10
star
10

esm-loader-hook

Loader hook for ESM instrumentation (experimental!!)
JavaScript
10
star
11

sample-babel-node

Sample babel project to demonstrate source mapped coverage reports with istanbul
JavaScript
9
star
12

sample-mocha-compilers

Sample project to demo istanbul coverage with mocha using the babel compiler
JavaScript
7
star
13

test-exclude

test for inclusion or exclusion of paths using globs
JavaScript
7
star
14

istanbul-lib-processinfo

A module for reading and writing in NYC's processinfo data folder
JavaScript
3
star
15

load-nyc-config

Utility function to load nyc configuration
JavaScript
2
star
16

schema

Schemas describing various structures used by nyc and istanbuljs
JavaScript
1
star
17

assets

logos, fonts, graphics, and other assets.
1
star