Created
May 5, 2020 01:05
-
-
Save silverbirder/71135913192fbca51a7e26924bd36b8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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