LogoLogo
  • Planet 4
  • Development
    • Contribute
    • Installation
    • Git Guidelines
    • Coding Standards
    • Continuous Delivery
  • CI/CD
    • Test Instances
    • Deployment
    • Testing
      • End-to-end Tests
      • Visual Regression Tests
  • NRO Customization
    • Development
      • Using Child Themes
      • Package Registry
      • Plugins
    • Testing
      • Visual Regression Tests
    • Deployment
      • Production
      • DB/Media Sync
  • Infrastructure
    • NRO Generation
    • ElasticSearch
    • Cloudflare
  • Recipes
    • Maintenance page
    • Production sync
    • Running commands
  • Platform
    • Practices
    • ADRs
      • [ADR-0001] Use Gitbook for Technical Documentation
      • [ADR-0002] P3 Archive elastic search integration
      • [ADR-0003] WYSIWYG Blocks Architecture
      • [ADR-0004] Switch to Monorepo
      • [ADR-0006] Define scope for deployment environments
      • [ADR-0008] PSR-4 Autoloading Standard
      • [ADR-0009] Include Media Library in master theme
      • [ADR-0011] PHP Coding Standards
      • [ADR-0012] Use custom SCSS syntax for variables
      • [ADR-0013] Choose a ticketing system
      • [ADR-0014] Choose a testing framework
      • [ADR-0015] Use block templates to build block patterns
      • [ADR-0016] Form Builder data retention policy
      • [ADR-0017] Move blocks into the theme
    • Changelog
      • 2024
      • 2023
      • 2022
      • 2021
      • 2020
      • 2019
      • 2018
  • Tech
    • Wordpress
    • Blocks
    • Plugins
    • Hooks
    • Data migrations
    • CSS variables
Powered by GitBook
On this page
  • Automated Visual Regression testing
  • How to see the report
  • Manual Visual Regression testing
  • Backstop infra code
Edit on GitHub
  1. CI/CD
  2. Testing

Visual Regression Tests

Catching frontend regression bugs

PreviousEnd-to-end TestsNextDevelopment

Last updated 1 year ago

In order to catch css regression bugs before they land on production, or ideally before even merged, we use use a tool () for comparing visual changes, test regressions and verify changes.

The way this tool works is that it creates a series of screenshots for predefined urls and device resolutions and it automatically recognizes visual differences caused by our css code changes and reports them back in a way we can easily inspect them on browser and decide if these are within accepted threshold or not.

Automated Visual Regression testing

By default, for all Planet 4 websites, when their staging website is being build/deployed, the following happens:

  1. Before the deployment, a screenshot of certain elements is taken

  2. After the deployment a new screenshot is taken

  3. A report is generated to see if the two screenshots match.

When a backstopjs job fails on staging, the workflow triggers a "Hold" workflow for the developers to visually look at the report, and decide if they want to proceed or not.

If the backstopJS job does not fail the workflow triggers directly the production deploy pipeline.

How to see the report

  1. Go to the CircleCI workflows for your website

  2. Get in the latest production workflow.

  3. Find the job visualtests-compare and get into it (click it so that you go in the details)

  • Go to the tab artifacts.

  • Drill down to find the folder html_report

  • Click on index.html. It will open in a new tab the report with the comparisons

If you are happy with result go back to the workflow and approve the hold-production job.

Manual Visual Regression testing

Developers can run the regression tests locally as they work on a feature branch.

Backstop infra code

The test get run by a custom Planet 4 docker image that includes all the necessary dependencies for backstopJS and the scripts relevant to the above workflow.

In the readme file of the above repository you can read how you can do modifications and local testing.

You can either mount the same docker image to your local docker environment and modify the json file, or you can go full hardcore and install and configure BackstopJS locally. There is a simple backstop configuration already to get started.

The docker image is generated by the repository and the docker images are stored in .

The default page and viewport settings are controlled by the file in the above repository.

inside the master-theme
planet4-backstop
docker hub
backstop.json
BackstopJS
visual tests job
backstop find report
hold approve