Covered in this doc
How to configure Percy to run locally
Percy works best when triggered automatically from your CI environment, but can also be run from your local development environment. This comes in helpful when you're first setting up Percy integration. To enable Percy locally, the PERCY_TOKEN environment variable must be configured:
PERCY_TOKEN: The Percy project's write-only API token. This is unique for each Percy project.
When running in your local environment, we also recommend setting the
PERCY_BRANCH environment variable to local to avoid unintentionally overwriting your project's
master baseline in Percy. This isn't required but it's a step to make sure you're not throwing off any baselines that may have been set by CI.
You can set environment variables locally using
$ export PERCY_TOKEN=aaabbbcccdddeeefff $ export PERCY_BRANCH=local $ $ # Now run your tests locally (just an example, depends on client library used): $ npm test
Or, all on one line:
$ PERCY_TOKEN=aaabbbcccdddeeefff PERCY_BRANCH=local npm test
Careful when running locally
If you don't use
PERCY_BRANCHwhen you run tests locally, and you are on the
masterbranch it will set your project's
masterbaseline in Percy.
IMPORTANT: Keep your Percy token secret. Anyone with access to your token can consume your account quota, though they cannot read data.
Updated almost 2 years ago