AngularJS路由测试未知提供程序
我正试图在路由器上设置jasmine测试,就像这样AngularJS路由测试未知提供程序,angularjs,testing,jasmine,karma-runner,router,Angularjs,Testing,Jasmine,Karma Runner,Router,我正试图在路由器上设置jasmine测试,就像这样 it('should map routes to controllers and templates', function() { inject(function($route) { module('igt'); expect($route.routes['/'].controller).toBe('mainPageCtrl'); expect($route.routes['/'].t
it('should map routes to controllers and templates', function() {
inject(function($route) {
module('igt');
expect($route.routes['/'].controller).toBe('mainPageCtrl');
expect($route.routes['/'].templateUrl).toEqual('html/pages/main.html');
// otherwise redirect to
expect($route.routes[null].redirectTo).toEqual('/')
});
});
而我的路由器文件是(因为它很长,所以只能乞讨):
我在karma.conf.js文件中插入了这些文件:
// list of files / patterns to load in the browser
files: [
'../../node_modules/angular/angular.js',
'../../node_modules/angular-mocks/angular-mocks.js',
'../app.js',
'../router.js',
'unit/*.js'
],
现在,当我开始用业力开始测试时,它给了我错误:
错误:[$injector:unpr]未知提供程序:$routeProvider将其更改为
describe('Testing Routes', function () {
beforeEach(module('myApp'));
it('should map routes to controllers and templates', function($route) {
expect($route.routes['/'].controller).toBe('mainPageCtrl');
现在我有了
phantomjs2.1.1(Windows 8 0.0.0)测试路由应该映射到控制器和模板失败类型错误:未定义不是单元/testAngularUnitSpec.js(第4行)中的对象(评估“$route.Routes['/'])
发生了什么?
describe('Testing Routes', function () {
beforeEach(module('myApp'));
it('should map routes to controllers and templates', function($route) {
expect($route.routes['/'].controller).toBe('mainPageCtrl');