конф карма
// list of files / patterns to load in the browser
files: [
'../Scripts/angular.js',
'../Scripts/angular-mocks.js',
'../Scripts/angular-route.js',
'../service.js',
'../home-view/home-view.module.js',
'../home-view/home-view.component.js',
'../home-view/home-view.template.html',
'../home-view/home-view.component.spec.js'
],
// list of files / patterns to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'../home-view/home-view.template.html' : 'ng-html2js',
'../home-view/home-view.component.spec.js' : ['coverage']
},
ngHtml2JsPreprocessor: {
moduleName: 'templates'
},
home-view.component.spec.js
'use strict';
describe('component test : home', function () {
// add module reference you want to test
beforeEach(module('homeView'));
// add templates [from karma]
beforeEach(module('templates'));
var element;
var scope;
beforeEach(inject(function ($rootScope, $compile) {
scope = $rootScope.$new();
element = angular.element('<home-view></home-view>');
scope.$apply(function () {
$compile(element)(scope);
});
}));
it('render the header text', function () {
var title = element.find('a');
expect(title.text()).toBe('Header Text');
});
});
Я получаю эту ошибку.
Error: Unexpected request: GET home-view/home-view.template.html
No more request expected
at createFatalError (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular-mocks.js:1569:19)
at $httpBackend (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular-mocks.js:1616:11)
at sendReq (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:13257:9)
at serverRequest (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:12998:16)
at processQueue (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:17914:37)
at C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:17962:27
at Scope.$digest (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:19075:15)
at ChildScope.$apply (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:19463:24)
at UserContext.<anonymous> (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js:17:15)
at Object.invoke (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular.js:5122:19)
at <Jasmine>
at window.inject.angular.mock.inject (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/Scripts/angular-mocks.js:3422:25)
at Suite.<anonymous> (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js:14:16)
at <Jasmine>
at C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js:3:1
Error: Expected '' to be 'Header Text'.
at <Jasmine>
at UserContext.<anonymous> (C:/Projects/IntervieweeApp/IntervieweeSPA/IntervieweeSPA/home-view/home-view.component.spec.js:24:30)
at <Jasmine>
Почему яполучить эту ошибку?Я пытаюсь написать модульный тест для этого компонента и пока не смог найти никакого решения.Даже если я прокомментирую весь код в контроллере и шаблоне, ошибка не изменится.Мой тест написан правильно?В контроллере есть http запросы, но даже если их нет, ничего не меняется.Может ли это быть связано с параметрами контроллера?