angularjs - testing controller

后端 未结 1 1675
滥情空心
滥情空心 2021-01-06 02:49

I am just starting with angular and I wanted to write some simple unit tests for my controllers, here is what I got.

app.js:

\'use strict\';


// Dec         


        
相关标签:
1条回答
  • 2021-01-06 03:49

    You need to set up your Prototype module first.

    beforeEach(module('Prototype'));
    

    Add that to your test, above the current beforeEach would work.

    describe("DashboardController", function () {
      var ctrl, scope;
    
      beforeEach(module('Prototype'));
    
      beforeEach(inject(function ($rootScope, $controller) {
        scope = $rootScope.$new();
        ctrl = $controller('DashboardController', {$scope: scope});
      }));
    
      it("has repeats attribute set to 5", function () {
        expect(scope.repeats).toBe(5);
      });
    });
    
    0 讨论(0)
提交回复
热议问题