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

casperjs-assert-match-snapshot

v1.0.1

Published

casperjs tester extension to assert snapshots matched

Downloads

10

Readme

casperjs-assert-match-snapshot

NPM Version Build Status codecov License

Extension to CasperJS tester, with more lightweight, test-friendlier API than unmaintained PhantomCSS, to assert snapshots matched.

Install

  npm i casperjs-assert-match-snapshot

Usage

Basic

In casper test suite:

  require('casperjs-assert-match-snapshot');


  casper.test.begin('Test case', function begin(test) {
    casper.start()
      .then(function () {
        test.assertMatchSnapshot('snapshot-file-name');
      })
      .then(function () {
        // other tests
      });
    casper.run(function () {
      test.done();
    });
  });

Update snapshots

When run this first time, or when page is modified, to update snapshots, set this command option:

  casperjs test casper.suites.js --updateSnapshot

Set default options

There are several options to further define its behaviour. All of them have predefined values. You can change them of course

  var init = require('casperjs-assert-match-snapshot');
  init(options);

Override default options in specific call

To apply specific options for a certain call, instead of the global settings:

  test.assertMatchSnapshot('snapshot-file-name', selector, options);

Options

  • folder: string, 'snapshots'

    Directory where snapshots being placed, relative to current working directory.

  • format: string, 'png' (allowed formats based on your engine.)

    The snapshot file format

  • keepTemp: boolean, false

    Whether to leave temporary snapshot files which are tested against the original one in file system. Removed by default. These files have a prefix of temp_ in file name.

  • maxDiff: number, 0 (0 - 100)

    How much the maximum difference being be tolerant of is allowed. None by default, e.g. they should be totally identical.

  • quality: number, 75 (0 - 100)

    The quality of snapshot image for certain formats.

API

  casper.test.assertMatchSnapshot(filename: string, selector: string | Object, options: Object): casper

Parameters

  • filename: string, required

    The filename of this snapshot file, excluding extension.

  • selector: string or Object, optional

    Specify the area of this snapshot. When undefined, implies the whole page. If string, it should be a valid selector. Or a json object defining the bounds ({ left, top, width, height }). Refer to this doc.

  • options: see above

returns

casper

Caveat

  • It calls waitFor internally, so if the next steps depends on that test, please execute in then.

License

MIT.