npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@penskemediacorp/backstopjs-config

v1.62.0

Published

Visual regression testing with Backstop JS.

Downloads

1,454

Readme

Backstop JS Config

This npm package provides configuration for visual regression, or screenshot, testing with Backstop JS.

Overview of Functionality

  1. Backstop JS and Chromium are installed as npm packages.
  2. This package's entry point (index.js) gets project-level configuration from larva.config.js and provides useful defaults for the Backstop JS configuration object.
  3. When the appropriate npm script is used, the object exported from index.js is passed to backstop CLI as configuration.
  4. Backstop uses that configuration object when it runs the tests.

Development Setup

First install the package and its dependencies. This includes headless Chrome, so will take a moment.

  1. Install the package. Run this command from the same location as package.json.

    npm install @penskemediacorp/backstopjs-config backstopjs --save-dev
  2. Add configuration to larva.config.js. You can either test modules from the Larva repo, or test a full page screenshot at specific paths.

    Configuration for testing Larva modules:

    // larva.config.js
    
    module.exports = {
    
    	// This object will provide project-level overrides for the Backstop config.
    	backstop: {
    		// If testing default Larva patterns, replace "project" with "larva", in this path:
    		testBaseUrl: 'http://localhost:3000/project',
    		larvaModules: [ 'footer', 'breadcrumbs' ],
    		backstopConfig: {
    			// This is required for testing on the Larva server. It is not required for testing external URLs.
    			'engineOptions': {
    				'args': [ '--no-sandbox', '--proxy-server=127.0.0.1:3000', '--proxy-bypass-list=<-loopback>' ],
    			}
    		}
    	},
    }

    And configuration for testing a document and external URLs:

    // larva.config.js
    
    module.exports = {
    
    	// This object will provide project-level overrides for the Backstop config.
    	backstop: {
    		// Be sure to include HTTP password in the URL
    		testBaseUrl: 'https://pmc:[email protected]',
    		// Use the testPaths property instead of larvaModules. These are appended to the testBaseUrl.
    		testPaths: [ '/', '/v/film' ]
    	},
    }
  3. Add the npm script to package.json:

    "scripts": {
    	"backstop": "backstop --config=node_modules/@penskemediacorp/backstopjs-config"
    }

Running the Tests

After you have added the configuration, it is time to run the tests.

  1. You must first generate reference screenshots from a master branch, or other branch that contains the UI you want to test against. When you are on that branch, run the following:
    # Generate reference screenshots
    npm run backstop -- reference
  2. Checkout to your feature branch, or the branch that contains changes you want to test for regressions.
  3. Run the test with:
    # Run the tests, then open an HTML page with a UI for viewing results.
    npm run backstop -- test

Things To Be Aware Of

  • Testing full pages with ads will likely time out. There is a Puppeteer script for hiding ads, but it is currently disabled.

History and Changelog

This package started as part of PMC Build Utils, and was migrated to the pmc-larva monorepo during the AMH redesign project to take advantage of the shared environment for developing Larva-specific tooling.

Support

Post questions in the #larva Slack channel and @laras126. Refer to the Backstop JS documentation for troubleshooting, and consider using the search term Puppeteer when googling for solutions.