cloudchen / grunt-template-jasmine-requirejs

RequireJS template for grunt-contrib-jasmine task
111 stars 97 forks source link

Script files seem to be in a different order now #78

Open parris opened 9 years ago

parris commented 9 years ago

As of 0.2.2 the script files are being loaded up in a way that breaks our test runner. Here is our config:

module.exports = function (grunt) {
    'use strict';

    grunt.config.set('jasmine.reserved', {
        src: [
            'src/core/spec_helper.js',
            'src/core/require_config.js',
            'src/core/spec_require_config.js'
        ],
        options: {
            display: 'short',
            keepRunner: true,
            summary: true,
            specs: ['src/**/*.spec.js', 'node_modules/jasmine-jquery/lib/jasmine-jquery.js'],
            vendor: ['bower_components/sinonjs/sinon.js', 'bower_components/jasmine-sinon/lib/jasmine-sinon.js'],
            helpers: 'src/!(core)/**/spec_helper.js',
            template: require('grunt-template-jasmine-requirejs'),
            templateOptions: {
                version: '2.1.10'
            }
        }
    });

};

We reverted back to 0.2.0 and everything with our test runner was fixed. It seems like jasmine is now being included after jasmine-sinon.

cloudchen commented 9 years ago

As with v0.2.2, vendor and helpers files load in respective order. Try to adjust them based on your purpose.

ryan0122 commented 9 years ago

I have the same issue. I changed the order locally but this will not work in my Jenkins build since it can\'t see my local change to node_modules

cloudchen commented 9 years ago

@ryan0122 , can you explian it in more deatil? I don't get it. @parris , does v0.2.2 work for you?

ryan0122 commented 9 years ago

In the template the vendor scripts are being loaded before the core jasmine files which results in "jasmine" being undefined when using the jasmine-jquery plugin. I can manually change the order of the scripts being loaded in the template to work locally. However in my build job in Jenkins one of the tasks is "npm install" to install all node_modules based on package.json. Therefor my local changes won't be reflected in Jenkins. Reverting to 0.2.0 where the scripts are loaded correctly fixed my issue,

prantlf commented 5 years ago

@ryan0122, the loading order has changed. When #65 git fixed, by 890766c3a22bb359ca5dd6cc79343e6610b381d7, not only the require.js script was moved, but the other scripts as well:

polyfills, vendor, requirejs, jasmine, boot, helpers, src, specs, reporters

Use vendor for including scripts before requirejs and jasmine. Use helpers for including scripts after requirejs and jasmine. Sinon qualifies for the latter.

If vendor had moved after requirejs it would allow loading stuff after requirejs, but before jasmine:

polyfills, requirejs, vendor, jasmine, boot, helpers, src, specs, reporters

I admit, that there's probably no real-world use case for this...