2016-08-18 49 views
0

我使用业力测试我的角应用程序中的控制器,应用程序它自我运作如预期,但单元测试抛出error: unexpected request: GET views/home.html 因为我得到的问题是由ui路由器和$ httpBackend。这样一种方法是通过缓存“卡玛 - 预处理”,但我所做的是:意外GET请求在业力单元测试

var MenuController, scope, $httpBackend; 
// Initialize the controller and a mock scope 
beforeEach(inject(function($controller, _$httpBackend_, $rootScope, menuService) { 
// place here mocked dependencies 
$httpBackend = _$httpBackend_; 
$httpBackend.whenGET("views/header.html").respond(200,''); 
$httpBackend.expectGET("http://localhost:3000/dishes").respond([{ .... 

但得到错误显示了我的意见的文件夹每个模板。

现在有没有办法忽略所有的模板和任何其他意外的GET请求?

回答

0

您可以创建的所有模板匹配的请求正则表达式: httpBackend.whenGET(/views\/.*\.html/).respond(200, {});或仅 httpBackend.whenGET(/views\//).respond(200, {})