I want to use grunt to run jasmine tests automatically. I have never done that before and I am constantly facing errors I don't understand...
I want to use grunt-contrib-jasmine
and grunt-template-jasmine-requirejs
.
I added this to my grunt file:
jasmine: {
jasmine_tests: {
src: 'public/js/app/**/*.js',
options: {
specs: 'spec/*Spec.js',
helpers: 'spec/*Helper.js',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfig: {
baseUrl: '',
paths: {
"i18n": "../libs/require-i18next/require-i18next/i18next",
"i18next-builder": "../libs/require-i18next/require-i18next/i18next-builder",
"jquery": "../libs/jquery/dist/jquery",
...
},
shim: {
"jquerymobile": ["jquery"],
....
}
}
}
}
}
},
When I run grunt jasmine
i get hundreds of errors. It seems that not a single file can be loaded.
Running "jasmine:jasmine_tests" (jasmine) task
Testing jasmine specs via PhantomJS
Error: scripterror: Illegal path or script error: ['jquery'] at ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3_SpecRunner.html:38 ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3.grunt\grunt-contrib-jasmine\require.js:12 v ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3.grunt\grunt-contrib-jasmine\require.js:30 Error: scripterror: Illegal path or script error: ['underscore'] at ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3_SpecRunner.html:38 ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3.grunt\grunt-contrib-jasmine\require.js:12 v ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3.grunt\grunt-contrib-jasmine\require.js:30
...
Error: timeout: Load timeout for modules: i18n!locales_unnormalized2,datatables,sortDate...
...
http://requirejs.org/docs/errors.html#timeout at ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3_SpecRunner.html:38 ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3.grunt\grunt-contrib-jasmine\require.js:12 v ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3.grunt\grunt-contrib-jasmine\require.js:14 C ..........\C:\Users\Garrarufa\Documents\WebstormWorkspace\website3.grunt\grunt-contrib-jasmine\require.js:14
Warning: PhantomJS timed out, possibly due to an unfinished async spec. Use --force to continue.
Aborted due to warnings.
My specs are int the folder .../website3/specs
, my requirejs module definitions that I want to test are in the folder .../webiste3/public/js/app/**
.
What is going wrong and what do I have to change?
I don't really understand what i have to define in the gruntfile and in requireConfig. Maybe this has to do with it?
My directory structure:
- website3
- .grunt
+ grunt-contrib-jasmine
+ node_modules
- public
- js
- app
+ collections
- config
> config.js
+ ...
- views
+ ...
> AddVehicleView.js
> ...
+ libs
> index.html
+ server
- spec
+ helpers
- support
> jasmine.json
> AddVehicleViewSpec.js
> .bowerrc
> ...
> _SpecRunner.html
> Gruntfile.js
> package.json