I'm a complete noob with Jasmine and RequireJS so any help is appreciated.
We have the following directory structure
/assets
/libs <- populated by Jam
/scripts
/tests
I'm trying to setup Jasmine + Grunt + RequireJS to run my tests however I keep getting the following error, when I run my grunt task grunt jasmine I've reviewed the error on RequireJS site but in my view everything is in place.
Error: scripterror: Illegal path or script error: ['scripts/MyModule']
Here is my Jasmine setup in my gruntfile.js
jasmine: {
src: 'assets/scripts/**/*.js',
options: {
specs: 'tests/*spec.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: '/assets',
paths: {
'jquery': 'libs/jquery/dist/jquery'
}
}
}
}
Here is a dead simple test spec :)
require(['scripts/MyModule'], function (myModule) {
'use strict';
describe('A suite', function() {
it('should pass this test', function() {
expect(myModule).not.toBe(null);
});
});
});
RequireJS works fine in my project, here is the setup that I run for that...
<script>
var require =
{
baseUrl: '/assets'
};
</script>
<script src="/assets/libs/require.js"></script>
Where am I going wrong, what can I do to fix it?
Well I got it running, had to make the following change in the Jasmine config in my Gruntfile.js
baseUrl: './assets/'
It needed to step one directory up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With