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

@eightshapes/esds-avr-generator

v0.5.1-alpha.0

Published

_Powered by [BackstopJS](https://garris.github.io/BackstopJS/)_

Downloads

15

Readme

ESDS Avr Generator

Powered by BackstopJS

Installation

Run the initializer:

npx @eightshapes/esds-avr-generator --init

This will:

  1. Install @eightshapes/esds-avr-generator as a dev dependency in your project
  • Allow you to configure your test file location and any CSS selectors you use to wrap your test screenshots
  • Ask if you'd like to use Docker to run your tests (recommended)
  • Add scripts to package.json that allow you to set up, run and approve tests

Usage

Capture reference images

Before running tests for the first time, reference images must be captured that represent the "valid" state of your tests. To capture reference images run:

npm run avr-reference

After reference images have been captured subsequent tests can be run.

Running tests

After making changes to the codebase that alter the visual output of your tests, run AVR to verify the changes are intentional and nothing unintentional has changed as a side effect.

npm run avr-test

After the tests have run the BackstopJS UI will be opened in the browser to display the test results:

Passing Tests

Approving changes

If tests fail during a test run, but the changes the failures represent are intentional, then approving those changes is the next step. To approve changes run:

npm run avr-approve

The most recent test images will be promoted to reference images and will be used on subsequent test runs.

Advanced features

Filtering

Limiting the number of AVR tests during a run is important as the test suite grows larger. Use the --filter flag to limit which tests are run.

For example given the following test URLS:

  • test/button.html
  • test/card.html
  • test/icon.html

To run only the tests for Button, run:

npm run avr-test -- --filter=button

Similarly to approve new images only for Button, run:

npm run avr-approve -- --filter=button

Backstop config

The initializer will configure your initial test options for you and create a backstop.js config file in the root of your project. If you need to add additional pages for testing, or you want to add other options, like testing across different viewports, refer to the BackstopJS documentation

Running via Docker

To run tests across multiple host platforms, use Docker. This ensures a consistent, sandboxed environment for the tests to run, regardless of the host's platform.

Be sure to first install Docker Desktop (Free) for your platform:

Depending on the docker configuration specified during ESDS AVR installation, tests may already be configured to run via Docker by default. To determine if that's the case, refer to backstop.js in the root of your project.

Near the end should be a line that looks like:

module.exports = { ...localConfig, dockerDefault: true };

If dockerDefault is set to true then tests will always be run in a Docker container. To disable this functionality, set dockerDefault to false.

Running with Docker flag

When dockerDefault is set to false, tests can be conditionally run via Docker using the --docker flag. For example:

npm run avr-test

with dockerDefault=false will run the tests locally in the host environment.

npm run avr-test -- --docker

will run the tests in a Docker container.

This can be useful for debugging.

How's it all work?

You want to know what's happening under the hood? It's fairly straightforward:

  1. Before taking reference images or running tests, esds-avr spins up a local server using BrowserSync. This happens behind the scenes.
  2. ESDS AVR then passes the browser sync server config to backstop so the test URLs can be configured to point to the local server.
  3. Tests are run or reference images are captured
  4. After backstop has finished, the local server is shut down
  5. If tests were run, the default browser is launched showing the BackstopJS HTML report