错误:意外请求:GET layouts/index.html-AngularJS单元测试-Karma
因为我的错误:意外请求:GET layouts/index.html-AngularJS单元测试-Karma,angularjs,unit-testing,karma-runner,httpbackend,Angularjs,Unit Testing,Karma Runner,Httpbackend,因为我的app.config文件包含在我的测试中,所以我得到了那个错误。这使得我所有涉及httpbackend的单元测试都失败了。它们通常是这样的: beforeEach(function(){ module('consumerApp'); inject(function($injector) { httpBackend = $injector.get('$httpBackend'); }); }); describe('foo', function(){ it('do
app.config
文件包含在我的测试中,所以我得到了那个错误。这使得我所有涉及httpbackend的单元测试都失败了。它们通常是这样的:
beforeEach(function(){
module('consumerApp');
inject(function($injector) {
httpBackend = $injector.get('$httpBackend');
});
});
describe('foo', function(){
it('does something', inject(function(Foo){
httpBackend.when("POST", URL).respond(json);
Foo.something();
httpBackend.flush();
expect(Foo.stuff).toEqual('done');
}));
});
我不知道为什么单元测试需要调用我的模板来运行…你的app.config是什么样子的?你必须找到这个GET请求来自哪里,如果这是一个预期的行为(动态加载),通过设置
httpBackend.expectGET('layouts/index.html'),在测试中处理它
(操作前)和httpBackend.flush()代码>(操作后)找到问题的解决方案了吗?没有。我现在从单元测试文件中删除了config.js文件。