Grunt task for running Buster.JS tests in Node.js or headless in PhantomJS
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-buster
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-buster');
Then, you must install Buster.JS:
npm install buster
If you want to run tests for the browser environment, you also need to install PhantomJS:
npm install phantomjs
In your project's Gruntfile, add a section named buster
to the data object
passed into grunt.initConfig()
. You then need to define at least one target
for grunt buster
to have any effect.
Example of a minimal working configuration:
buster: {
foo: {}
}
The buster
object can have an arbitrary number of targets, like foo
in the
above example. If you run grunt buster
, all targets are executed. If you run
grunt buster:foo
, only the foo
target is executed.
No options are needed to get started, as grunt-buster will use default values if none is specified.
An object with options passed as command line arguments to buster test
. For
available options for buster test
run:
buster test --help
An object with options passed as command line arguments to buster server
. For
available options for buster server
run:
buster server --help
Growl support is optional. If you would like to use it follow the instructions
on how to install node-growl, then
enable Growl notifications in the buster
task in your Gruntfile.
Example:
buster: {
options: {
growl: true
}
}
You should now get notifications whenever your test suite passes or fails.
buster: {
foo: {
test: {
config: 'path/to/my/buster.js'
},
server: {
port: 1111
}
},
bar: {
options: {
growl: false
}
},
options: {
growl: true
}
}
The above config will for the foo
target run buster test
with the
argument --config path/to/my/buster.js
, and run buster server
with the
argument --port 1111
, with Growl notifications when the tests complete.
For the bar
target, default configuration will be used, and Growl
notifications will be turned off.
It is possible to start one or more Buster.JS servers, PhantomJS instances or individual Buster.JS test runs by passing Grunt arguments when invoking tasks.
Grunt allows for command line arguments to be passed to multitasks, like so:
grunt task:subtask:argument1:argument2
. To pass arguments to, and execute all
subtasks of a multitask, skip the subtask name: grunt task::argument
. In
grunt-buster
, we use that to gain more granular control over which Buster.JS
components are executed, as described below in this section.
grunt buster::server
This starts all configured Buster.JS servers, without starting a Phantom.JS instance nor running any tests.
Note: Grunt will not block the server
and phantomjs
tasks by default. They
are intended to be used in combination with blocking tasks like
grunt-contrib-watch
. If you do not want to run either of the two in
combination with a watch command, you can supply the block
argument:
grunt buster::server:block
grunt buster::phantomjs
This allows you to capture browsers manually before executing the tests separately (see below).
Execute the tests only and not spawn neither a Buster.JS server nor PhantomJS, as they are assumed to be started manually in some other way.
grunt buster::test
If you wish to contribute, please ensure a green test suite.
Install development dependencies:
npm install
Running the test suite:
npm test
Starting a watch loop listening to file changes and running the test suite:
npm start
- Update the
Release history
- Update the
package.json
version number - Tag the release commit with correct version number
- Push new release to
npm
:npm publish
- Using
cross-spawn-async
so that a correct executable is resolved on Windows
- Cleaning up redundant project settings
- Try to use an executable in the path, if an npm package for it not found
- BREAKING: added an engine requirement (node LTS) in
package.json
- Use
resolve-bin
to findbuster
andphantomjs
executables - Add
buster
as a peer dependency - Clean escape characters in Growl
- Fix issue where failing tests make grunt-buster hang
- Fix #9 - Allow for more granular control over
buster-server
,PhantomJS
andbuster-test
execution - Only log buster-server output if Grunt is run with
verbose
- Fix broken URLs in package description
- Updated project URLs after move to busterjs organization on GitHub
- Require Node.js >= 0.8.0
- Fix
path.existsSync
deprecation warning - Declare a peer dependency on Grunt ~0.4.0
- Made Growl notifications optional. You must now install the
growl
package from npm and setoptions.growl
totrue
to get notifications. - Added support for Grunt multi-tasks. You must now define at least one target
for the
buster
task to have any work to do. See the above docs for a minimal config example. (Thanks to Richard Nespithal) - Add
--server
option tobuster-test
(Thanks to Andreas Köberle) - Add support for locally installed versions of Buster.JS and PhantomJS (Thanks to Stein Martin Hustad)
- Looks for buster.js in test/ and spec/ in addition to the root folder
- Fixed corrupt error.png and ok.png (Thanks to Paweł Maciejewski)
- Removed console non-printable characters from growl text message (Thanks to Paweł Maciejewski)
- Ensure that tests is not run until PhantomJS finished starting (thanks to Harrison)
- Initial release