Closed netpoetica closed 11 years ago
The repo itself is a self-running example of grunt-contrib-jasmine and this template.
To aid in troubleshooting you can build the specrunner and open it in a browser, eg if your task is named "jasmineTest", run grunt jasmine:jasmineTest:build
and a _SpecRunner.html
file will be generated in your project's root.
It may be worthwhile to fork this repo and configure a template that suits your setup better. Requirejs configurations vary drastically from project to project and the more configuration you have the more custom your setup will need to be.
Okay, giving this a shot. It would definitely be helpful to see what order this lib is loading my scripts in and if it is finding them. I'm not sure where your "jasmineTest" is coming from though. I added a task called jasmineTest and linked it to ['jasmine'], but grunt doesn't like it:
➜ grunt-contrib-jasmine-example git:(master) ✗ grunt jasmine:jasmineTest:build
Running "jasmine:jasmineTest:build" (jasmine) task
Verifying property jasmine.jasmineTest exists in config...ERROR
>> Unable to process task.
Warning: Required config property "jasmine.jasmineTest" missing. Use --force to continue.
Aborted due to warnings.
So instead I removed the task and tried:
grunt jasmine:build
but no _SpecRunner.html was generated. Here is my Gruntfile.js if there's anything maybe you could flag as me being a durp:
module.exports = function(grunt) {
'use strict';
// Project configuration.
grunt.initConfig({
meta : {
src : 'public/**/*.js',
specs : 'spec/**/*.js'
},
watch: {
test : {
files: ['<%= meta.src %>','<%= meta.specs %>'],
tasks: 'test'
}
},
jasmine : {
src : '<%= meta.src %>',
options : {
template: require('grunt-template-jasmine-requirejs'),
specs : '<%= meta.specs %>',
templateOptions: {
requireConfig: {
paths: {
Backbone: '/js/libs/backbone',
jQuery: '/js/libs/jquery',
Underscore: '/js/libs/underscore'
},
shim: {
'Backbone': ['Underscore', 'jQuery']
}
}
}
}
},
jshint: {
all: [
'Gruntfile.js',
'<%= meta.src %>',
'<%= meta.specs %>'
],
options: {
jshintrc: '.jshintrc'
}
}
});
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('jasmineTest', ['jasmine']);
grunt.registerTask('test', ['jshint', 'jasmine']);
// Default task.
grunt.registerTask('default', ['test']);
};
I see you've opened and closed other repos related to grunt and the grunt 0.4.0 changes. Let me know if you still have issues configuring jasmine with the template.
Closing, let me know if there are further problems.
Is there any possibility, when you have some time, that you could get put together a bare bones example like https://github.com/jsoverson/grunt-contrib-jasmine-example ?
I can get Jasmine working, I can get grunt working, but as soon as I throw require into the mix it's just error after error after error. I think there are a lot of discrepencies between where the Gruntfile.js file lives and where my actual public/js/*.js source code lives, and how the requireConfig needs to handle different path resolution.
It would be extra helpful if it were in the context of an MVC framework, for example, a directory structure like: