1.9 KiB
1.9 KiB
Basic Use
Sample configuration to run Pivotal Labs' example Jasmine application.
// Example configuration
grunt.initConfig({
jasmine: {
pivotal: {
src: 'src/**/*.js'
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js'
}
}
}
}
Supplying a custom template
Supplying a custom template to the above example
// Example configuration
grunt.initConfig({
jasmine: {
customTemplate: {
src: 'src/**/*.js',
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js'
template: 'custom.tmpl'
}
}
}
}
Sample RequireJS usage
// Example configuration
grunt.initConfig({
connect: {
test : {
port : 8000
}
}
jasmine: {
requirejs: {
src: 'src/**/*.js',
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js',
host: 'http://127.0.0.1:8000/',
template: 'requirejs',
templateOptions: {
requireConfig: {
baseUrl: 'src/'
}
}
}
}
}
}
Note the usage of the 'connect' task configuration. You will need to use a task like grunt-contrib-connect if you need to test your tasks on a running server.
RequireJS notes
If you end up using the requirejs template, it's worth looking at the
RequireJS template source
in order to familiarize yourself with how it loads your files. The load process essentially
consists of a series of nested require
blocks, incrementally loading your source and specs:
require([*YOUR SOURCE*], function() {
require([*YOUR SPECS*], function() {
require([*GRUNT-CONTRIB-JASMINE FILES*], function() {
// at this point your tests are already running.
}
}
}