mercredi 1 juillet 2015

How to work with third-party libraries when doing unit-testing?

I'm a newbie when it comes to unit-testing, I've tried to do a unit-test with Karma and Jasmine from an app that already existed.

Basically the app has a lot of dependencies from different third-party libraries being used. So when I tried to create a unit-test a stumbled upon a lot of errors from Karma/Jasmine. One of them is the screenshot below:

unit-test-error

From the screenshot, I'm getting an unknown provider: socketFactoryProvider, which I've traced down and found out that it belongs to the btford.socket-io module. So what I've did was to have a code like this to mock the dependencies:

// Set the app module
beforeEach(function () {
    angular.module('btford.socket-io', []);

    module('opensportsAdmin');
});

But I'm still getting an error (based on the screenshot).

So my question is, how can you work with third-party libraries for your unit-test? I'm kind of new and didn't find any articles that can help me with my problem.

Here's a reference to my code.

Aucun commentaire:

Enregistrer un commentaire