2016-07-21 4 views
1

테스트를 배우려고하고 있으며 많은 문제가 있습니다. 여기 각도 1.5 구성 요소를 테스트하는 데 문제가 있습니다.

내 아주 기본적인 구성 요소입니다

(function() { 
    "use strict"; 

    angular.module("testList", []) 
    .component("testList", { 
     templateUrl: "test-list.component.html", 
     controllerAs: "model", 
     controller: testController 
    }); 

    function testController() { 
    var model = this; 
    model.test = "test"; 
    } 
}()); 

내 테스트에서 할 노력하고 모든 "테스트", "테스트"에 해당 있는지 확인하는 것입니다,하지만 난 내 콘솔에 다음과 같은 오류를 얻고있다 : undefined is not a function

"use strict"; 

describe("Testing Component", function() { 
    var $componentController; 

    beforeEach(module('testList')); 

    beforeEach(inject(function(_$componentController_) { 
    $componentController = _$componentController_; 
    })); 

    it("should see if test equals test", function() { 
    var ctrl = $componentController('testList', null, { test: "test"}); 
    expect(ctrl.test).toEqual("test"); 
    }); 
}); 

누군가 나를 도울 수 있습니까?

답변

1

당신이 거기에 뭐가 잘못한 것처럼 보이지 않습니다. JSBin 코드는 https://jsbin.com/cefefabobo/edit?html,js,output과 같습니다 (다소 차이가 있음). 테스트가 통과됩니다.

아마도 angular-mocks.js 스크립트를 올바르게로드하지 않았습니까?

관련 문제