/percy-snap

Parameterized screenshot container for Percy.io

Primary LanguageJavaScript

PercySnap - Automated Visual Regression + Notifications

Github version Docker Stars Docker Pulls

Automate website screenshot uploads to Percy.io for visual regression testing with this parameterized Docker container. Designed to work locally or in remote clusters. Enable Slack notifications to get pinged when a site changes.

Usage

Docker CLI

Set environment variables and run:

docker run -d \
  -e PERCY_TOKEN=xxx \
  -e PERCY_TARGET_URL=https://google.com \
  -e CRON_TIME=daily \
  --name percysnap

docker logs -f percysnap

Docker-Compose

Create .env from the sample, then run with Docker Compose:

docker pull emcniece/percysnap:latest
cp .env.sample .env
# ... edit .env
docker-compose up

Behaviour

  • Runs a snapshot on container start
  • Reads CRON_TIME env for job scheduling
  • CRON_TIME can be set to "daily" for a random time
  • Scheduled runs are managed by node-cron

Development

npm install
node index.js

New Project Automation

The new-project.js script uses Puppeteer to automate the bulk creation of projects. Dumps a list of project names and PERCY_TOKENs.

Populate the email, password, and org variables in .env and execute. Requires a Percy account that has the email/password login method enabled.

node new-project.js project1 project2 ...
# { 'project1': 'xxx', 'project2': 'yyy' }

Todo

  • Optimize image, reduce size
  • Split PERCY_WAIT on comma to allow multiple ready conditions
  • Log waits for visibility
  • Epic: Handle multiple projects
    • Parse optional JSON config file
      • projects: [{"percy_token": "xxx", "percy_target_url": "xxx", "percy_wait": "1000"}]
    • Parse optional ENV vars
      • PERCY_TOKEN1... PERCY_TOKEN(N)
      • PERCY_TARGET_URL1... PERCY_TARGET_URL(N)
      • PERCY_WAIT1... PERCY_WAIT(N)
    • Deep-merge ENV with JSON config