grunt-snapshots

Take screenshots of your evolving front-end periodically during development.

npm install grunt-snapshots
1 downloads in the last week
16 downloads in the last month

grunt-snapshots

Take screenshots of your evolving front-end periodically during development.

Getting Started

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-snapshots --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-snapshots');

Note You must also have PhantomJS installed and have the phantom executable in your PATH. See the PhantomJS home for installation instructions.

The "snapshots" task

Overview

In your project's Gruntfile, add a section named snapshots to the data object passed into grunt.initConfig().

grunt.initConfig({
  snapshots: {
    options: {
      // Task-specific options go here.
    },
  },
})

Options

    filename: 'pic',
    path: 'tmp/custom/pics',
    extension: 'png',
    url: 'http://localhost:9001',
    unique: false

options.filename

Type: String Default value: 'pic'

A string value that is used to do something with whatever.

options.path

Type: String Default value: 'tmp/default/screenshots'

Path to the folder in which to keep screenshots.

options.extension

Type: String Default value: 'png'

File extension to write to. Valid formats are 'gif', 'jpeg', 'pdf', and 'png'.

options.url

Type: String Default value: 'http://www.google.com'

The URL of which to take screenshots. Use Grunt's grunt-contrib-connect Plugin to open a server to test localhost.

options.unique

Type: Boolean Default value: false

This option will append a random string of alphanumeric characters to the end of each screenshot's filename.

options.timestamp

Type: Boolean Default value: false

This option will append a Unix timestamp to the end of each screenshot's filename.

Usage Examples

Default Options

This example will place a png screenshot of http://www.google.com inside a tmp/default/screenshots folder.

grunt.initConfig({
  snapshots: {
    options: {},
  },
})

Custom Options

In this example, a screenshot is taken of a test index.html file is served on http://localhost:9001 from the test/fixtures folder.

grunt.initConfig({
  connect: {
    server: {
      options: {
        hostname: 'localhost',
        port: 9001,
        base: 'test/fixtures',
      },
    },
  },
  snapshots: {
    options: {
      filename: 'pic',
      path: 'tmp/custom/pics',
      extension: 'png',
      url: 'http://localhost:9001',
      unique: false,
      timestamp: true
    },
  },
})

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

0.1.0 Initial release.

npm loves you