Angularjs Ui路由器端到端测试
我正在尝试使用使用ui路由器的angular应用程序创建端到端测试 我希望它切换状态,让它的行为完全像“真实”运行的应用程序 我遇到的问题是,状态确实被切换,状态的解析似乎得到了正确的解析,但是状态的控制器没有得到实例化 例如: 国家定义Angularjs Ui路由器端到端测试,angularjs,jasmine,angular-ui-router,end-to-end,Angularjs,Jasmine,Angular Ui Router,End To End,我正在尝试使用使用ui路由器的angular应用程序创建端到端测试 我希望它切换状态,让它的行为完全像“真实”运行的应用程序 我遇到的问题是,状态确实被切换,状态的解析似乎得到了正确的解析,但是状态的控制器没有得到实例化 例如: 国家定义 $stateProvider.state('project', { controller: 'RootCtrl', template: '<div>Empty</div>' url: '/', resol
$stateProvider.state('project', {
controller: 'RootCtrl',
template: '<div>Empty</div>'
url: '/',
resolve {
anything: function() {console.log('This Gets Called!');}
}
}
单元测试
it('should switch state', function () {
var app = this.$controller('AppCtrl', {$scope: this.$rootScope.$new()});
this.$state.go('project');
this.$httpBackend.flush();
this.$interval.flush(100);
this.$rootScope.$digest();
this.$rootScope.$apply();
// Controller never instantiated!
});
it('should switch state', function () {
var app = this.$controller('AppCtrl', {$scope: this.$rootScope.$new()});
this.$state.go('project');
this.$httpBackend.flush();
this.$interval.flush(100);
this.$rootScope.$digest();
this.$rootScope.$apply();
// Controller never instantiated!
});