Unit Testing + Jasmine + Angular

Hi,

 

i am getting all the time "encountered a declaration exception". I am trying to write my first unit test for a factory. It seems like mocking doesn't really work.

The paths to do references look like this:

///<reference path="~/App/js/jasmine/jasmine.js"/>
///<reference path="~/App/js/lib/40_Angular/angular.js"/>
///<reference path="~/App/js/jasmine/angular-mocks.js"/>

///<reference path="~/App/app.js"/>
///<reference path="~/App/services/userService.js"/>

My sample tests look like this:

describe("userService", function () {

beforeEach(module("issApp"));

describe("userService", function () {

var userService;

beforeEach(inject(function () {
userService = $injector.get('userService');
}));

it('should be true', function () {
expect(true).toBeDefined();
});

it('should have a farbSchema', function () {
expect(userService.getParameter("ngFarbSchema")).toBeDefined();
});
});
});

 

My app.js is declared like this:

iss.app = angular.module("issApp", ["ng", "ui.router" ...]);

userService.js is declared like this:

iss.app.factory("userService", function ($q, $http)

This are the version of the tools I use:

Resharper: 8.2.1

Angular: 1.5.8

Visual Studio: 2013

Jasmine: 2.4.1

 

What am i doing wrong? What means the status question sign (from the screenshot)?

Please sign in to leave a comment.