cedmax/grunt-qunit-amd

Tests locking up

Closed this issue · 5 comments

Thanks for working on this! Unit tests with AMD seems to be a real pain, glad some folks are working on it.

I've set up a very simple configuration (only two grunt tasks) and it appears the tests are locking up. I'm not waiting on any asynchronous calls either so not sure what may be causing it. Here is what I see in my console:

Running "jshint:all" (jshint) task
>> 2 files lint free.

Running "qunit_amd:test" (qunit_amd) task

################
# test/test.js #
################

And here is my grunt config for the qunit_amd task:

'qunit_amd': {
    test: {
        tests: [
            'test/**/*.js'
        ],
        require: {
            baseUrl: './',
            paths: {
                scripts    : 'scripts/',
                jquery     : 'components/jquery/jquery',
                Handlebars : 'components/handlebars/handlebars',
                text       : 'components/requirejs-text/text',
                hbars      : 'components/requirejs-handlebars/hbars'
            },
            shims: {
                jquery : {
                    exports : 'jquery'
                },
                Handlebars : {
                    exports : 'Handlebars'
                }
            }
        }
    }
}

And my test file:

/* globals QUnit, test, ok */
require(['jquery'], function($){
    'use strict';

    QUnit.start();

    module('myLibraryTest', {
        setup: function(){
            $('<div id="domDependency"></div>').appendTo(document.body);
        },
        teardown: function(){
            document.body.innerHTML = '';
        }
    });

    test('my test', function(){
        var myDiv = $('#domDependency');
        ok(myDiv, 'everythings is fine');
    });

});

Appreciate any help getting this working!

Hi, I tried to reproduce your setup and everything works fine for me, may I ask you to double check that you are using the latest (~0.0.5) version of my lib. the older might be kind of broken.

Are you on a mac/linux/windows? What version of node?
Do you mind sending me a zip file to marco@cedmax.com to let me check the actual project setup and see if I missed something trying to reproduce it?

On a mac. Version 0.0.5 of the lib. Node 0.10.10.

This is a fresh project. Have a look.

So it seems there is a issue with your version of node: using node <0.10 (I tried 0.8.24 & 0.9.12) it works as expected.

It might take a few days to me to get into this issue properly, do you have the option to use an older version of node in the meanwhile?

Thanks for opening the issue, I wouldn't have noticed this as I'm stuck to an older node version due to some other dependencies.

I figured that might have been the case. I had to upgrade my node version to accommodate for another task that only worked with >0.10. I might be able to make a tradeoff somewhere.

Update: There's a great tool for doing this: https://github.com/creationix/nvm

Would make it really easy to sweep various node versions as part of a test suite. For different projects I can include swapping out node versions as another task so this is pretty seamless.

Running your tool just fine now, thanks!

I've been trying with some node versions and everything seems to work just fine with node 0.11, would you be able to move to this node version?
it seems that the npm module node-phantom doesn't work properly on node 0.10 and I couldn't figure out why, I filed a issue to them, but anyway it is not anything I change on my codebase to let it work properly