Percy Developer Hub

Welcome to the Percy Developer Hub. You'll find comprehensive guides and documentation to help you start working with Percy as quickly as possible, as well as support if you get stuck. Let's jump right in!


Integrating Percy with your Puppeteer scripts

Covered in this doc

Integrating Percy with your Puppeteer tests
Installing and importing percySnapshot()
Calling and configuring percySnapshot(page, <snapshotName>, <options>)

percy-puppeteer on GitHub

Package Status CircleCI This project is using for visual regression testing.


If you're not ready to integrate Percy, check out our 2-minute Puppeteer testing tutorial and example app with Percy for Puppeteer already added.

These docs apply to version 1.0.0 or later. Previous versions of @percy/puppeteerare incompatible with what is described in this document.

Install @percy/puppeteer using npm:

npm install --save-dev @percy/puppeteer

Or using yarn:

yarn add --dev @percy/puppeteer

In order to start creating snapshots from your Puppeteer scripts or tests, you'll need to import the percySnapshot() function from the @percy/puppeteer package. You will need to do this in each file from which you want to take snapshots:

const { percySnapshot } = require('@percy/puppeteer')

You will then use percySnapshot(...) to generate a snapshot:

describe('Integration test with visual testing', function() {
  it('Loads the homepage', async function() {
    const browser = await puppeteer.launch()
    const page = await browser.newPage() 
    await page.goto(TEST_URL)
    await percySnapshot(page, this.test.fullTitle())

Finally, wrap your script or test runner command in the percy exec command. This will start a Percy agent to receive snapshots from your tests and upload them to your Percy dashboard. For example, if you are using Mocha for your tests, your new test command becomes:

percy exec -- mocha

Note the double dash, --, between percy exec and your test run command.

That's it! Now, whenever your tests run with the percy command, a snapshot of the app in that state will be uploaded to Percy for visual regression testing!

For an example showing how to add Percy snapshots to an existing Puppeteer test suite, see


percySnapshot(page, snapshotName)
percySnapshot(page, snapshotName, options)

page is the Puppeteer Page object that you want to snapshot. Required.

snapshotName is a required string that will be used as the snapshot name. It can be any string that makes sense to you to identify the page state. It should be unique and remain the same across builds. For more details on generating snapshot names, see Autogenerated snapshot names.

options is an optional hash that can include:

  • widths: An array of integers representing the browser widths at which you want to take snapshots.

  • minHeight: An integer specifying the minimum height of the resulting snapshot, in pixels. Defaults to 1024px.

For example:

percySnapshot(page, 'Homepage test');
percySnapshot(page, 'Homepage responsive test', { widths: [768, 992, 1200] });

Global configuration

You can also configure Percy to use the same options over all snapshots. To see supported configuration including widths read our Configuration doc.

What's next

Once you've set up Percy for Puppeteer, the next step is to add Percy to your CI service. That way, every time CI runs, Percy will automatically kick off visual tests as well.

CI integration overview


Integrating Percy with your Puppeteer scripts

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.