Question

I was trying to write some javascript unit tests, using requirejs and jsTestDriver intellij plugin. When I run them in the IDE I have no error even when there are some. I only see them when opening my browser console. Did someone manage to make IDE plugin displays failures into a require function ? My code below and some screen shots illustrating my problem.

TestCase("Collections", {
    "test User Collection": function () {
        require(['lib/underscore', 'lib/backbone', 'app/user', 'app/collections'],
            function (_, Backbone, user, appCollections) {
                assertNotUndefined('Users must be defined', appCollections.users);
                assertTypeOf('Users must be backbone collection', typeof Backbone.Collection, appCollections.users);
                assertTypeOf("Users' model must be a user", typeof Backbone.Model, appCollections.users.model);
            });
    }
});

Intellij jsTestDriver plugin test result

My browser console

Was it helpful?

Solution

I haven't tested this, but it might get you started:

var CollectionsTest = AsyncTestCase('Collections');

CollectionsTest.prototype.testIt = function(queue) {

  queue.call('Step 1', function(callbacks) {

    function test1(_, Backbone, user, appCollections) {
        assertNotUndefined('Users must be defined', appCollections.users);
        assertTypeOf('Users must be backbone collection', typeof Backbone.Collection, appCollections.users);
        assertTypeOf("Users' model must be a user", typeof Backbone.Model, appCollections.users.model);
    }

    var onModulesLoaded = callbacks.add(test1);

    require(['lib/underscore', 'lib/backbone', 'app/user', 'app/collections'], onModulesLoaded);

  });

};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top