grunt-snapshots

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

grunt-snapshots

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

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.

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. 
    },
  },
})
    filename: 'pic',
    path: 'tmp/custom/pics',
    extension: 'png',
    url: 'http://localhost:9001',
    unique: false

Type: String Default value: 'pic'

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

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

Path to the folder in which to keep screenshots.

Type: String Default value: 'png'

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

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.

Type: Boolean Default value: false

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

Type: Boolean Default value: false

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

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

grunt.initConfig({
  snapshots: {
    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
    },
  },
})

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.

0.1.0 Initial release.