我正在測試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