Sne*_*sta 5 javascript testing unit-testing jasmine angularjs
我有以下单元测试,由于某种原因,第二次测试使其他测试失败.
beforeEach(inject(function ($rootScope, _$httpBackend_, $controller, $location, mockedResource) {
scope = $rootScope.$new();
httpBackend = _$httpBackend_;
locationService = $location;
ctrlDependencies = {
$scope: scope,
resource: mockedResource,
}
var ctrl = $controller('myController', ctrlDependencies);
}));
it('should redirect to a new page', function() {
scope.pageRedirectFunction();
expect(locationService.path()).toBe('/newpage')
});
it('should delete an epic resource', function() {
httpBackend.expectGET('/api/v1/epic/1').respond({});
httpBackend.expectDELETE('/api/v1/epic/1').respond({});
// Run the deletion function
scope.deleteEpicResource()
httpBackend.flush() // This line seems to be the rebelious one
expect(scope.epicResources.length).toEqual(0)
})
Run Code Online (Sandbox Code Playgroud)
我已经设法弄清楚似乎导致错误的httpBackend.flush()
线,这就是线.为什么flush函数会导致奇怪的行为?
我karma start
在终端中运行命令得到的实际错误是:
Delaying execution, these browsers are not ready: Chrome 29.0 ....
Run Code Online (Sandbox Code Playgroud)
过了一会儿,Chrome会话就崩溃了.
归档时间: |
|
查看次数: |
2910 次 |
最近记录: |