grunt-ghoul
Ghoul integrates with existing in-browser test runners provided by popular frameworks such as QUnit and Mocha, works asynchronously out of the box and stays out of your way.
Getting Started
This plugin requires:
- Node
0.10
- Grunt
~0.4.1
- PhantomJS
- Some server like Connect running so that PhantomJS can load the runners.
Supported runners:
- Mocha 1.12+
Overview
Ghoul acts as a bridge between your standard HTML test runner and Grunt. It takes the resulting HTML, parses it and reports on the results. Since you emit events back to Ghoul from the HTML runner, it natively supports asynchronous behavior.
The major difference between how grunt-lib-phantomjs
receives messages and how Ghoul sends them is that Ghoul sends them via the console rather than using alert()
. This is so you don't get any annoying alerts if you want to run your tests in the browser, eliminates the need for having PhantomJS checks around them and facilitates simpler debugging if and when you want to see what was sent back to Ghoul.
The following shows how to load Ghoul and configure it.
grunt;grunt
Sample Test Runner
The following is a sample test runner for Mocha. RequireJS is used to exemplify how asynchronous front-end testing can work with Ghoul.
Contributing
- Fork.
- Write tests.
- Code.
- Document.
- Pull request.
License
Copyright (c) 2013 Trey Shugart
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.