home-view.module.js
angular.module('homeView', []);
home-view.component.js
angular.
module('homeView').
component('homeView', {
templateUrl: 'home-view/home-view.template.html',
controller: ['$scope', '$route',
function HomeViewController($scope, $route) {
this.name= "aaddeellhheeiiddee"; }]);
home-view.component.spec.js
'use strict';
describe('homeView', function () {
beforeEach(module('homeView'));
describe('controller', function () {
var ctrl;
beforeEach(inject(function ($componentController,) {
ctrl = $componentController('homeView');
}));
it('basic test', function () {
expect(ctrl.name).toBe("aaddeellhheeiiddee");
});
});
});
Карма выдает ошибку ниже
Chrome 72.0.3626 (Windows 10.0.0) базовый тест контроллера homeView FAILED Ошибка: [$ injector: unpr] Неизвестный поставщик: $ routeProvider <- $ route <a href="https://errors.angularjs.org/1.7.5/" rel="nofollow noreferrer">https://errors.angularjs.org/1.7.5/$injector/unpr?p0=%24routeProvider%20%3C-%20%24route в C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js: 138: 12 в C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js: 4905: 19 в Object.getService [asполучить] (C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js: 5065: 32) в C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js: 4910: 45 в getService (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:5065:32) atjectionArgs (C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js: 5090: 58) в Object.instantiate C:/ Проекты / IntervieweeApp / IntervieweeSPA / IntervieweeSPA / Scripts / Ангулаr.js: 5134: 18) в $ controller (C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js: 11688: 28) в C: / Проекты / IntervieweeApp / IntervieweeSPA / IntervieweeSPA / Scripts / angular-mocks.js: 2555: 14 в $ componentController (C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/IntervieweeSPA/Scripts/angular-mocks.js: 2611: 14) в at window.inject.angular.mock.inject (C: / Projects /IntervieweeApp / IntervieweeSPA / IntervieweeSPA / Scripts / angular-mocks.js: 3422: 25) в Suite.(C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js: 10: 14) в Suite.(C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js: 7: 2) в C: / Projects / IntervieweeApp / IntervieweeSPA / IntervieweeSPA / home-view / home-view.component.spec.js: 3: 1 TypeError: Невозможно прочитать свойство 'name' из undefined at в UserContext.(C: /Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js: 23: 25) в
Как мне получить свойство 'name' в тестовом файле?Спасибо