我正在测试Angular和Jasmine的角度指令。 嘲笑http后端工作正常,所有测试在本地都能正常工作。但是,在构建服务器,我得到:Jenkins构建服务器上的茉莉花测试错误与角度模拟?
Error: Unexpected request: GET app/auth/views/login.html No more request expected (line 1419) [email protected]_components/angular-mocks/angular-mocks.js:1419:90 [email protected]/vendor.js:222:54 build/vendor.js:219:263 build/vendor.js:254:21 [email protected]/vendor.js:268:347 [email protected]/vendor.js:265:425
我的测试设置:
beforeEach(angular.mock.module("app"));
beforeEach(() => {
inject(function ($injector, _$compile_, _$rootScope_) {
// The injector unwraps the underscores (_) from around the parameter names when matching
$compile = _$compile_;
$rootScope = _$rootScope_;
$httpBackend = $injector.get("$httpBackend");
});
$httpBackend.whenGET("api/langs/gb.json").respond({ "COMMON.HOME": homeName });
$httpBackend.whenGET("api/langs/de.json").respond({});
$httpBackend.whenGET("app/home/views/dashboard.html").respond(200, "");
$httpBackend.whenGET("app/home/views/login.html").respond(200, "");
$httpBackend.whenGET(/^private\/auth\?.*/).respond({});
directiveElem = getCompiledElement();
});
什么是构建服务器上的不同。我无法解释这种行为。
你可以显示你用来模拟'app/auth/views/login.html'文件的$ httpBackend代码吗? – TwitchBronBron
你能否也显示你的指令代码? – TwitchBronBron
您提供的示例中引用了'http://localhost/app/auth/views/login.html'。你如何在你的应用中包含'login.html'?你能分享包含该文件的代码吗? – TwitchBronBron