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控制器基本测试失败 错误:[$ injector:unpr]未知提供程序:$ routeProvider <-$ route 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 [获取时](C:/Projects/IntervieweeApp/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) 在injectionArgs(C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:5090:58) 在Object.instantiate(C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:5134:18) 在$ controller(C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:11688:28) 在C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular-mocks.js:2555:14 在$ componentController(C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular-mocks.js:2611:14) 在 在window.inject.angular.mock.inject(C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular-mocks.js:3422:25) 在套房。 (C:/项目/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js:10:14) 在 在套房。 (C:/项目/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:无法读取未定义的属性“名称” 在 在UserContext上。 (C:/项目/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js:23:25)
如何到达测试文件中的“名称”属性?谢谢