Backstop Generator

Terminology

Profile
An entity that contains a set of tests (Scenarios) you want to run. It also defines one or more Viewports.
Scenario
A representation of a page you want to visually test. Each Scenario belongs to a Profile.
Scenario Defaults
Common settings defined in a Profile that apply to all Scenarios unless individually overridden.
Viewport
Defines the window size for testing. Typically configured for mobile, tablet, and desktop breakpoints.

How to Use This Module

1. Configure the Module

  1. Navigate to Configuration > Development > Backstop Generator (/admin/config/development/backstop-generator).
  2. Test domain is pre-filled with the current site URL. In the Reference domain field, enter the URL of the site you want to compare against (typically the live production site).
  3. Scenario Defaults and Profile Parameters allow you to set default values that new Profiles will inherit. These settings apply to new Profiles only and can be adjusted later per Profile.

2. Configure Your Viewports

Click the Viewports tab. When the module is installed, Viewports are automatically generated based on your default theme’s breakpoints.

Use the Viewport Generator to generate Viewports for other enabled themes with configured breakpoints. You can also manually create a Viewport using the Add Viewport button in the upper right corner.

3. Configure Your First Profile

  1. Click the Profile tab. You’ll see an empty list if no Profiles exist.
  2. Click Add Backstop Profile in the upper right corner.
  3. Enter a descriptive Title and Description.
  4. Select the Viewports to use for this Profile.
  5. Customize the Profile Parameters and Scenario Defaults as needed.
  6. Scroll to the Scenario Generator section:
  7. Click Save and generate scenarios to create the Scenario list.
  8. Select the Scenarios to include and click Save.
  9. The Profile is now saved and a BackstopJS JSON file is generated.

Congratulations! You've created a visual regression test using BackstopJS.

4. Edit Any of Your Scenarios

If any Scenarios fail during testing, you can edit them individually. For example, hide dynamic elements like carousels using the hideSelectors setting.

Use the text filter to search for specific Scenarios you want to modify.

5. Run the Commands

Go to the Commands tab to view the terminal commands for running BackstopJS tests:

  1. Run the reference command to capture screenshots from the Reference site.
  2. Run the test command to compare those screenshots against your local or development environment.

Overview of BackstopJS

BackstopJS is an open-source tool designed for automating visual regression testing of web applications. It captures screenshots of web pages and compares them over time to detect unintended visual changes. This is especially helpful in Drupal projects for ensuring that theme changes or code updates do not introduce UI regressions.

Key Features

Explanation of Configuration Fields

For more information, see the BackstopJS GitHub Repository.