istanbuljs / puppeteer-to-istanbul

given coverage information output by puppeteer's API output a format consumable by Istanbul reports
ISC License
212 stars 46 forks source link

Unable to run coverage report on actual website #27

Open SwetlinaSatpathy opened 5 years ago

SwetlinaSatpathy commented 5 years ago

Hi,

I have recently started using puppeteer for my frontend project. Want to run coverage report. Tried using the example in https://github.com/bcoe/puppeteer-to-istanbul-example But this solution works for static js file as in example. When I replace the URL with some website URL, it doesn't work.

code -

const path = require('path')
const pti = require('puppeteer-to-istanbul')

;(async () => {
  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
  let url = 'file:///' + path.resolve('./index.html')  
  // await page.goto(url);
  await page.goto('https://www.google.com');

  // Disable JavaScript coverage
  const jsCoverage = await page.coverage.stopJSCoverage()
  pti.write(jsCoverage)
  await browser.close()
})()

I get the below error -

(node:132032) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'D:\Puppeteer\puppeteer-code-coverage-on-google.nyc_output\js\m=sb_wiz,aa,abd,async,dvl,foot,ifl,lu,m,mu,sf,spch,wft,xz7cCd,fEVMic?xjs=s1.js'

image image

My repo link - https://github.com/SwetlinaSatpathy/puppeteer-code-coverage-on-google

tinkerology commented 5 years ago

Does anyone have a workaround for this issue on Windows?