Skip to content

kupriyanenko/grunt-gremlins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-gremlins

NPM version

Grunt task for monkey testing library gremlins.js

Getting Started

This plugin requires Grunt ~0.4.0

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-gremlins --save-dev

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

grunt.loadNpmTasks('grunt-gremlins');

Gremlins task

Overview

gremlins.js is a monkey testing library written in JavaScript, for Node.js and the browser. Use it to check the robustness of web applications by unleashing a horde of undisciplined gremlins.

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

grunt.initConfig({
    gremlins: {
        options: {
            // Task-specific options go here.
        },
        your_target: {
            options: {
                // Target-specific options go here.
            }
        },
    }
});

Run this task with the grunt gremlins command.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

path (required)

Type: String

Path to local html page or external web page

test

Type: String

Path to js file with gremlins test

Usage Examples

There are three formats you can use to run this task.

Test application with inluding tests

Grunt task:

gremlins: {
  tests: {
    options: {
      path: './examples/basic.html'
    }
  }
}

./examples/basic.html:

<!doctype html>
<html lang="en">
<script src="../node_modules/gremlins.js/gremlins.min.js"></script>
<body>
  <p>Lorem ipsum dolor sit amet.</p>
  <script>
  var horde = gremlins.createHorde()
    .gremlin(gremlins.species.clicker());

  if (window.phantomHorde) {
    window.phantomHorde(horde, { nb: 20 });
  } else {
    horde.unleash({ nb: 20 });
  }
  </script>
</body>
</html>

Test application with injected tests in page

Grunt task:

gremlins: {
  local: {
    options: {
      path: './examples/basic.html',
      test: __dirname + '/examples/test.gremlins.js'
    }
  }
}

/examples/test.gremlins.js:

var horde = gremlins.createHorde()
    .gremlin(gremlins.species.clicker())
    .gremlin(gremlins.species.scroller())
    .mogwai(gremlins.mogwais.gizmo())
    .mogwai(gremlins.mogwais.fps());

window.phantomHorde(horde, { nb: 20 });

Specific targets with per target options

Grunt task:

gremlins: {
  local: {
    options: {
      path: './examples/basic.html'
    }
  },
  external: {
    options: {
      path: 'https://google.com',
      test: __dirname + '/examples/test.gremlins.js'
    }
  }
}

About

Grunt task for monkey testing library gremlins.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published