Run javascript tests in the Grails build!
The main goal for Karma is to bring a productive environment for javascript testing. The grails-karma plugin integrates this spectacular tool with Grails so unit and functional tests written in javascript can be executed during the build.
First, install Karma as described in the Karma's official documentation.
Make sure karma is on your path and working properly.
Then execute the following command to install the grails-karma plugin grails install-plugin grails-karma
.
grails-karma is ready to be executed right after its installation.
Just put your test files under the test/js-unit/
or test/js-functional/
directories and execute grails test-app
.
You can also use grails test-app karma:unit
or grails test-app karma:functional
to execute tests form a specific phase.
During development, I recommend using karma directly form the command line since it will execute tests for you as you change your files.
The default karma configuration uses Jasmine as the testing framework and Angular to interact with the browser on functional tests.
You can change any settings in the unit.conf.js
and functional.conf.js
files under conf/karma
.
There are only a few items, followed by a // can't touch this
comment, which the plugin relies on and should be left alone.
Don't worry aobut setting autoWatch
. grails-karma will override this option so tests are executed only once during the Grails build.
This is just the first version of this plugin and we are couting on your feedback to make this plugin better! Don't hesitate to send us an e-mail, create an issue on GitHub or, even better, submit a pull request.