gabaum10
gabaum10

Reputation: 3827

Karma + Jasmine reporting 0 tests run when there are tests

I'm trying to run some Jasmine tests in Karma but the tests are failing because it's saying that it ran 0 of 0 tests. Can someone tell me what I'm doing wrong?

The async request mock fires and hits the callback. Even when I go to the debugger, it says 2 tests completed in the debugger, but failing in the console. What gives?

describe('User Info Tests:', function () {
    describe('Fetch User Info:', function () {
        it("User Name should match", function(done) { 
            // mock async request
            getUserProfile(1, 2, function (userProfile) {
                var match = userProfile.displayName === 'Unit Test User';
                expect(match).toBeTruthy();                    
                done();
            }, function (msg) {
                done();
                throw msg;
            });                 
        });            
    });
});

See the screenshot below of the debug console of the tests running. You will see the tests ran with a status of SUCCESS.

Test debug console

Upvotes: 0

Views: 2180

Answers (1)

gabaum10
gabaum10

Reputation: 3827

So the problem was I wasn't including the karam-requirejs plugin in the karam.conf.js file. Apparently it doesn't want you to include your own copy of require.js in the files collection. Once I added that plugin in, everything just worked.

frameworks: ['jasmine-jquery', 'jasmine', 'requirejs'],

    plugins: [
        'karma-phantomjs-launcher',
        'karma-chrome-launcher',
        'karma-jasmine-jquery',
        'karma-jasmine',
        'karma-requirejs'
    ],

Make sure the karma-requirejs plugin is actually installed through npm and in your package.json as well!

Upvotes: 1

Related Questions