Run client-side mocha tests using phantomjs
A simple wrapper to run client-side mocha tests using mocha-phantomjs
This plugin requires Grunt
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-mocha-phantomjs --save-dev
Run this task with the
grunt mocha_phantomjs command.
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
PhantomJS is installed when installing using NPM.
The reporter that should be used. See the supported reporters for more information.
The file that the task should output the results to. If
output is specified, the task will always complete and not throw an error code if errors are found. The CI will determine if the build failed or not.
silent to true will prevent the results from being printed using stdout.
https:// urls to be passed to PhantomJS. Specified URLs will be merged with any specified
src files first. Note that urls must be served by a web server, and since this task doesn't contain a web server, one will need to be configured separately. The grunt-contrib-connect plugin provides a basic web server.
Additional arguments may be passed. See mocha-phantomjs's usage.
// Project configuration.gruntinitConfigmocha_phantomjs:all: 'test/**/*.html';
// Project configuration.gruntinitConfigmocha_phantomjs:options:'reporter': 'xunit''output': 'tests/results/result.xml'all: 'test/**/*.html';
Include the [grunt-contrib-connect plugin] to run a local server [grunt-contrib-connect plugin]: https://github.com/gruntjs/grunt-contrib-connect
// Project configuration.gruntinitConfigmocha_phantomjs:all:options:urls:''''connect:server:options:port: 8000base: '.';gruntregisterTask'test' 'connect' 'mocha_phantomjs';
This is a very basic implementation of mocha-phantomjs. Failed tests and errors do not bubble up for custom reporting. The idea of this is to be mainly used by a CI and let the CI manage the error reporting.