Skip to content

Instantly share code, notes, and snippets.

@silverbirder
Created May 5, 2020 01:05
Show Gist options
  • Save silverbirder/71135913192fbca51a7e26924bd36b8b to your computer and use it in GitHub Desktop.
Save silverbirder/71135913192fbca51a7e26924bd36b8b to your computer and use it in GitHub Desktop.
(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('http://example.com')
// Disable both JavaScript and CSS coverage
const [jsCoverage, cssCoverage] = await Promise.all([
page.coverage.stopJSCoverage(),
page.coverage.stopCSSCoverage(),
])
pti.write([...jsCoverage, ...cssCoverage])
await browser.close()
})()
/*
node index.js
nyc report --reporter=html
open coverage/index.html
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment