Grunt task to run CasperJS tests
I no longer use or maintain this plugin. Let me know if you are interested in maintaining this project.
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, install this plugin with this command:
npm install grunt-ghost --save-dev
Then add this line to your project's
####Basic use without options
Specify the files/directories of the tests you want to run in the
filesSrc array. Files will be run in alphabetic and numerical order.
I have included all the test command options listed in the CasperJS documentation and some options of my own.
ghost:dist:filesSrc: 'tests/userSuite/*'// CasperJS test command optionsoptions:// Allows you to pass variables to casper that can be accesed in files,// for example, if you used the following args object then// casper.cli.get('username') would return 'colin'args:username: 'colin'// Exports results of test to a xUnit XML filexunit: 'xunit/userSuite.xml'// Outputs additional log messagesdirect: true// Sets logging level, check outlogLevel: 'info'// Specifies files to be included for each test file, accepts file paths or globs as inputincludes:'tests/config.js''lib/jquery.min.js'// Adds tests from specified files before running the test suitepre: 'tests/pre-test.js'// Adds tests from specified files after running the test suitepost: 'tests/post-test.js'// Terminates test suite upon failure of first testfailFast: true// Specify a custom test runnerrunner: 'tests/customRunner.js'// grunt-ghost specific options// Prints the command given to CasperJSprintCommand: true// Prints list of filepathsprintFilePaths: true
Thanks to the CasperJS authors for making a great tool, the descriptions of the test command options are modifications from their documentation. I also want to thank the authors of grunt-casperjs and grunt-recess because I learned a lot from looking at their source.
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.
Copyright (c) 2013 Colin Wren Licensed under the MIT license.
- v1.0.13 Fixed Fix printCommand infinite loop bug
- v1.0.12 Fixed glob filematching
- v1.0.11 Enabled streaming output