I'm using the SoundCloud JavaScript SDK with AngularJS, and trying to run Karma tests on it. I keep getting the error Error: [$injector:modulerr] Failed to instantiate module SoundcloudApp due to: ReferenceError: Can't find variable: SC
when I run the tests.
The variable SC (provided by the SoundCloud API, when including the script) is used in an AngularJS service:
angular.module('SoundcloudApp').provider('SoundCloud', function() {
SC.initialize({
clientId: 'SeES8KzD8c44J9IU8djbVg'
});
this.$get = function($q) {
return {
getUser: function(id) {
// returns user object with a given id
var user = $q.defer();
SC.get('/users/' + id, function (userData, err) {
if (err) {
user.reject(err.message);
} else {
user.resolve(userData);
}
});
return user.promise;
}
};
};
});
Should I just mock this service? How do I do that?