puppeteer-to-istanbul-extra
v0.0.2
Published
convert from puppeteer's coverage output to a format that can be used by istanbul reports
Downloads
1
Maintainers
Readme
Puppeteer to Istanbul Extra
Convert coverage from the format outputted by puppeteer to a format consumable by [Istanbul][istanbul].
Introduction
Puppeteer-to-istanbul-extra is a fork of puppeteer-to-istanbul. It is basically the same as, but provides additional functionality.
Usage
To Output Coverage in Istanbul Format with Puppeteer
install puppeteer,
npm i -D puppeteer
.install puppeteer-to-istanbul-extra,
npm i -D puppeteer-to-istanbul-extra
.run your code in puppeteer with coverage enabled:
(async () => { const pti = require('puppeteer-to-istanbul-extra') 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(), ]); const options_obj = {output_dir: './.nyc_output'} pti.write([...jsCoverage, ...cssCoverage], options_obj) await browser.close() })()
Options
Puppeteer-to-istanbul-extra provides options for use with the write
method.
Here are the available options:
| Option name | Description | Type | Default |
| ----------- | ----------- | ---- | ------- |
| output_dir
| Directory to output coverage information | String
| ./.nyc_output
|
| backup
| Define backup characteristics for coverage files. If true, will backup existing files. | Boolean
| false
|
To Check Istanbul Reports
install nyc,
npm i nyc -g
.use nyc's report functionality:
nyc report --reporter=html
puppeteer-to-istanbul-extra outputs temporary files in a format that can be consumed by nyc.
see istanbul for a list of possible reporters.
Extras
Please see Puppeteer-to-Istanbul for additional information.