Git Product home page Git Product logo

happo's Introduction

Happo


This project is in maintenance mode. New development, including cross-browser support, easier CI integration, etc takes place at https://happo.io


Happo is a screenshot testing tool. Read more.

Installation

Happo comes bundled as an npm package. To install it, run

npm install --save-dev happo

You will also want to install a target plugin and an uploader plugin.

Introduction

Happo works by running twice. It first needs to run on the "current" version of the code (generally latest master) to take screenshots of the current version of your components. Then, it runs on the "next" version of the code (generally your working branch) to take new screenshots of your components and compare them to the earlier version.

To set this up, you define a set of examples that Happo will grab snapshots for. If a previous snapshot exists for a component, Happo will diff the new snapshot with the previous. If a diff is found, a visual representation of the changes will be constructed. You can then use that diff image to decide whether a visual regression has been introduced or not, and take appropriate action based on that information.

Demo of Happo in action

Configuration

Happo loads configuration in one of the following ways:

  • From a JavaScript file specified via a HAPPO_CONFIG_FILE environment variable
  • From .happo.js in the current working directory

Example configuration

var FirefoxTarget = require('happo-target-firefox');
var S3Uploader = require('happo-uploader-s3');

module.exports = {
  // the name of the summary file
  // (default is shown below)
  resultSummaryFilename: 'resultSummary.json',
  
  // A function that returns an "Uploader" interface for CI.
  // (default: null)
  uploader: () => new S3Uploader(),

  // Specify the folder where snapshots are saved
  // (default: 'snapshots')
  snapshotsFolder: 'happo-snapshots',

  // An array of "targets" to run. Targets specify the environment to run
  // the snapshots in. Must specify at least one.
  // (default: [])
  targets: [
    new FirefoxTarget({
      // ... configuration for FirefoxTarget
    }),
  ],
};

Targets

At the moment, happo only has one target, but more are coming!

Uploaders

At the moment, happo only has one uploader, but more are coming!

Command line API

happo run [<targetName>]

This command will run all of the snapshots in the provided target name. If target name is omitted, then all targets are run.

happo review

Once happo run has finished, run happo review from the command line. This will open a page that compares the latest run's snapshots against the previous snapshots.

happo debug <targetName>

If you want to debug rendering your examples, you can run happo debug. This will open a browser window pointing at /debug, listing all your examples. If you click one of them, the example will be rendered in isolation and you can do use your developer tools to debug.

happo upload [<triggeredByUrl>]

Uploads all current diff images using the uploader specified in the config.

If you want the diff page to link back to a commit/PR, you can pass in a URL as the argument to happo upload. E.g.

happo upload "https://test.example"

happo upload-test

Uploads a small text file to an AWS S3 account. This is useful if you want to test your S3 configuration. Uses the same configuration as happo upload does.

happo upload-test

Running in a CI environment

The main purpose for Happo is for it to be run in a CI (Continuous Integration) environment. The command line tools provided are designed to be used as building blocks in a script that you can run in Travis, Jenkins and other Continuous Integration environments.

Below is an example of how you can use Happo to test if a commit introduces any visual change.

  1. Check out the commit previous to the one to test (e.g. git checkout HEAD^)
  2. (optionally) build your JavaScript and/or CSS
  3. Run happo run to generate previous snapshots
  4. Check out the commit to test
  5. (optionally) build your JavaScript and/or CSS
  6. Run happo run to diff against previously created snapshots
  7. Run happo upload to upload diffs to a publicly accessible location

There's an example script implementing these steps located in happo_example.sh. Use that as a starting point for your own CI script.

In the wild

Organizations and projects using Happo.

happo's People

Contributors

trotzig avatar lencioni avatar lelandrichardson avatar oliviertassinari avatar janpaul123 avatar

Watchers

James Cloos avatar Madhav S avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.