angularjs beforeEach encountered a declaration exception

2,256 views
Skip to first unread message

Johan Rabie

unread,
Mar 27, 2014, 11:45:32 AM3/27/14
to jasmi...@googlegroups.com
Hi I am new to jasmine.
Using Visual Studio to test some angular stuff.

Test file looks like this:
'use strict';

///<reference path="jasmine.js"/>
///<reference path="../../Scripts/angular.min.js"/>
///<reference path="../../Scripts/angular-route.min.js"/>
///<reference path="../../Scripts/angular-mocks.js"/>
///<reference path="../application.js"/>

describe('StatusPage Tests', function () {
    describe('Application Functions', function () {
        var location;

        beforeEach(module("StatusApplication"));

        beforeEach(inject(function($location) {
            location = $location;
        }));

        it('DetermineRootUrl_Application_RootUrl', function () {
            var result = DetermineRootUrl(location);

            var expectedResult = 'https://localhost/OK59SP1/';
            expect(expectedResult).toBe(expectedResult);
        });
    });
});

it seems like any angular mock function gives a "encountered a declaration exception"
if I use beforeEach on it's own it does not give a problem.
As soon as I try to inject something like $location, it just refuses to work.
Any help would be greatly appreciated.

Ben Loveridge

unread,
Mar 27, 2014, 12:28:12 PM3/27/14
to jasmi...@googlegroups.com, Johan Rabie
Are you using the mocks correctly? Here’s how I set mine up.

    beforeEach(function() {
        mocks.module(‘myModule');
    });
    beforeEach(mocks.inject(function($rootScope, $compile, $q, $httpBackend) {
        …
    }));



-- 
Ben Loveridge
--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at http://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages