studentsss
studentsss

Reputation: 197

KARMA Reference error:angular is not defined

I have a asp.net mvc app . In Scripts I have the subfolder app containing Controller.js. I also have another subfolder Spec containint ControllerSpec.js - written with jasmine.

 describe('PhoneCat controllers', function () {
    beforeEach(module('phonecatApp'));

    describe('PhoneListCtrl', function () {

        it('should create "phones" model with 3 phones', inject(function ($controller) {
            var scope = {},
            ctrl = $controller('PhoneListCtrl', { $scope: scope });

            expect(scope.phones.length).toBe(3);
        }));
    });
});

In SpecRunner.cshtml i have just included this files:

 <script type="text/javascript" src="/Scripts/app/controllers.js"></script>
<script type="text/javascript" src="/Scripts/Spec/controllersSpec.js"></script>

In karma init, I have added the path of those 2.js. Can you please tell me how can I do to make it work? If I run vs the Jasmine code it's ok.

Thx

Upvotes: 0

Views: 746

Answers (2)

Sten Muchow
Sten Muchow

Reputation: 6701

There could be a variety of reasons for such an error, so it would help to solve with a bit more info on your part.

However off hand and having seen this error before in my battles through angular unit testing, I have to ask are you including a link to angular-mocks.js?

The lastest repo: http://code.angularjs.org/1.2.15/

Angular Mocks: http://code.angularjs.org/1.2.15/angular-mocks.js

A copy of your karma.conf.js would also help....

Upvotes: 1

Yaniv Efraim
Yaniv Efraim

Reputation: 6713

You must add a reference to angular.js as well

Upvotes: 1

Related Questions