percy/percy-puppeteer

More helpful error logging during script injection

Chrissy opened this issue · 3 comments

It would be really helpful to have better error logging here:

try {
await page.addScriptTag({
path: agentJsFilename()
})
} catch (err) {
// Certain CSP settings prevent Puppeteer from injecting scripts. See:
// https://github.com/GoogleChrome/puppeteer/issues/2644
console.log(`[percy] Could not take snapshot named '${name}', maybe due to stringent CSPs. Try page.setBypassCSP(true).`)
return
}

I get the CSP error pretty regularly when setting up stuff with Percyscript, and CSP usually isn't the problem. Right now, I have a setup that works locally but fails in CI, and it would be extremely helpful to know what is actually throwing the error here.

I also got this error earlier in the setup, but again it wasn't a CSP issue. I simply didn't have my Percy token loaded into the env properly. It probably took me 5x as long to debug because of the misleading and unhelpful message.

Looks like we start to address this in the next iteration of the SDK: https://github.com/percy/percy-puppeteer/blob/ww/new-cli/index.js#L66-L96

Awesome good to hear! I did eventually solve my issue (It wound up being an incorrect version of node) but some kind of specific error messaging would have helped a ton.

Closing with the release of v2 🎉