0
service
을 삽입 할 때마다 아래 오류가 발생합니다.karma : TypeError : 정의되지 않은 'prototype'속성을 읽을 수 없습니다.
(function() {
describe('Test', function() {
var $scope, $state, service,ctrl;
beforeEach(function() {
module('moduleApp');
module(function($provide) {
$provide.service('AppService', service);
});
inject(function($rootScope,$injector,$controller,AppService) {
$scope = $rootScope.$new();
$state = $injector.get('$state');
service = $injector.get('AppService');
ctrl = $controller('MyCtrl', {
$scope: $scope,
$state: $state,
AppService: service
});
});
});
it('should have a working UserSession service', function() {
expect(service).to.exist;
});
});
}());
오류 :
TypeError: Cannot read property 'prototype' of undefined
at Object.instantiate (bower_components/angular/angular.js:4577:82)
at Object.<anonymous> (bower_components/angular/angular.js:4438:24)
at Object.invoke (bower_components/angular/angular.js:4570:17)
at Object.enforcedReturnValue [as $get] (bower_components/angular/angular.js:4422:37)
at Object.invoke (bower_components/angular/angular.js:4570:17)
at bower_components/angular/angular.js:4387:37
at getService (bower_components/angular/angular.js:4529:39)
at Object.invoke (bower_components/angular/angular.js:4561:13)
at Context.workFn (bower_components/angular-mocks/angular-mocks.js:2524:20)
at window.inject.angular.mock.inject (bower_components/angular-mocks/angular-mocks.js:2496:37)
Error: Declaration Location
at window.inject.angular.mock.inject (bower_components/angular-mocks/angular-mocks.js:2489:25)
at Context.<anonymous> (test/unit/app/views/Test.js:17:13)
내 제어기 ... CTRL = $ 제어기 ({서비스 : $ 범위, $ 상태 : $ 상태 AppService $ 범위} MyCtrl ') 아래와 같이 AppService 대한 참조를 보유해야 – Shane
@Shane 답변을 업데이트했습니다. 그것을 살펴보고 아직도 문제가 있다면 알려주십시오. – Mehraban