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

kobold

v0.9.6

Published

Visual regression testing framework, comparing screenshots from multiple builds

Downloads

28

Readme

Kobold

Visual regression testing framework, comparing screenshots from multiple builds.

Build Status Coveralls Coverage Code Climate Grade

NPM version NPM License

NPM NPM

Coverage Report API Documentation

Gitter Support

Table of Contents

##Installation

Install this module with the following command:

npm install kobold

Install this module globally with the following command:

npm install -g kobold

This will make sure that you don't have to enter the whole path when running Kobold.

Add the module to your package.json dependencies:

npm install --save kobold

Add the module to your package.json dev-dependencies:

npm install --save-dev kobold

##Getting Started

Kobold can be executed by running kobold script in the bin directory of the package. When you installed the module globally, then you can us only kobold to run it.

Only one parameter is required to run the tests:

kobold test/ui/regression

With this parameter, Kobold starts running tests on the test/ui/regression directory. It analyzes what screens were already approved, what screens are available in the current build, and what screens it has to compare. Then, it creates the test-code and executes the image-comparison, creating the test results in the highlight directory.

Instead of implicitly using the last argument for the test-path, you can also be more specific and supply the --test-path parameter:

kobold --test-path test/ui/regression

By default, Kobold will look for four directories:

  • approved - All approved screens should be available in this folder. These are the "golden standard" images that will be used to compare them to build screens.
  • build - Screens that were just taken are saved in this folder. This is most likely done by some Selenium tests, taking screenshots and saving them in this directory. These images will be compared to the images in the approved folder, creating comparison result images in highlight.
  • highlight - Image comparison results of the latest test-run are saved in this folder. These images will highlight the differences between the approved-image and the build-image.
  • config - Custom configuration files (.js or .json) for image specific comparison options. Sometimes, it is helpful to tune the comparison of a specific image. These options overwrite globally set comparison options. They are also optional. See the Blink-Diff Project WebSite for more information on these options.

The folder names for approved, build, highlight, and config can be changed by supplying the parameters --approved-folder, --build-folder, --highlight-folder, and --config-folder respectively:

kobold --approved-folder "golden" --highlight-folder "differences" /test/ui/regression

This test-run will look for golden and differences for the approved and highlight folder respectively instead of using the default folder names. In this specific case, build was not changed.

Sometimes, you want the tests to fail when previously approved screens are missing from the build directory. This can be the case when for example the tests that created these screenshots didn't fully run. Use the --fail-orphans flag to make these tests fail:

kobold --fail-orphans test/ui/regression

The --fail-additions flag will fail tests for screens that are new, screens that were never approved before.

kobold --fail-orphans --fail-additions test/ui/regression

Kobold also supports all Mocha parameters which can be interspersed with the Kobold parameters:

kobold --slow 3000 --fail-orphans --fail-additions --reporter dot --test-path test/ui/regression

##Command-Line Since Kobold is built on top of Mocha, it supports all of its parameters in addition to the following:

  • approved-folder - Name of the approved folder (default: 'approved')
  • build-folder - Name of the build folder (default: 'build')
  • highlight-folder - Name of the highlight folder (default: 'highlight')
  • config-folder - Name of the config folder (default: 'config')
  • fail-orphans - Flag that determines that tests should fail when screens that were previously approved, being in the approve folder, are not found in the build folder.
  • fail-additions - Flag that determines that tests should fail when unapproved screens are found in the build folder, meaning screens that are missing from the approve folder.
  • test-path - Path to directory with all test related folders as mentioned above (required). Uses implicitly the last parameter element when none is given.
  • config - Path to a config file (.js or .json) that is used to overwrite comparison options. (default: none) See the Blink-Diff Project WebSite for more information on these options.

##Configuration The global configuration file that can be selected by supplying --config to the command-line describes default-values for the comparison.

Here is an example of the file (config.js - can also be a JSON file):

module.exports = {
	"delta": 35 // Changing the distance of pixel-comparison
};

This file then can be called as follows:

kobold --config config.js test/ui/regression

Configuration files for specific screens on the other hand describe only the comparison options for that screen. Here is an example for a screen that is named "YDN_Missing"; the path is config/YDN_Missing.json (could also be a .js):

{
	"outputBackgroundOpacity": 0.3,
	"outputBackgroundGreen": 100
}

This example will make the background for the comparison image look greener, and lightens-up the whole comparison by reducing the opacity of the background-mask.

##Examples Kobold creates a regular test report as if the tests were manually written, and it also creates the following images, comparing the approved (left) with the build screenshot (right), pointing out the differences (middle).

  • Changed color Screen1
  • Missing items Screen2
  • Messed-up sorting Screen3
  • Image swap Screen4
  • Text formatting Screen4

These examples can be found in the examples folder. The above results were produced by running the following command in the project root with a globally installed Kobold:

kobold test/ui/regression

##API-Documentation

Generate the API-documentation with following command:

npm run docs

This will generate the source-code documentation in the docs folder of the module root.

##Tests

Run the tests with the following command:

npm run test

The code-coverage will be written to the coverage folder in the module root.

##Project Name A Kobold is a gnome that can make itself invisible and is often the source of nuisances - so, pretty much like visual regressions.

##Third-party libraries

The following third-party libraries are used by this module:

###Dependencies

  • blink-diff: https://github.com/yahoo/blink-diff
  • preceptor-core: https://github.com/yahoo/preceptor-core
  • kobold-core: https://github.com/yahoo/kobold-core
  • log4js: https://github.com/nomiddlename/log4js-node
  • promise: https://github.com/then/promise
  • mocha: https://github.com/visionmedia/mocha

###Dev-Dependencies

  • chai: http://chaijs.com
  • istanbul: https://github.com/gotwarlost/istanbul
  • yuidocjs: https://github.com/yui/yuidoc

##License

The MIT License

Copyright 2014 Yahoo Inc.