嗨,大家好,午餐时我有这个错误karma karma.conf.js
20%20%20%20原子%20Object.createInjector%20%5Bas%20injector%5D%20(HTTP%3A%2F%2Flocalhost%3A9876%2Fbase%2FWebContent%2Fassets%2Fjs%2Fangular1.4.3%2Fangular.js %3Fbede50a38baeba3db7a4df46069 5d01ecb437273%3A4272%3A11)%0A%20%20%20%20原子%20Object.workFn%20(HTTP%3A%2F%2Flocalhost%3A9876%2Fbase%2FWebContent%2Fassets%2Fjs%2Fangular1.4.3%2Fangular-mocks.js %3F8bc8772418adb9b2fa9517 2525c3540d23e140f4%3A2393%3A52)%0A%20%20%20%20原子%20attemptSync%20(HTTP%3A%2F%2Flocalhost%3A9876%2FC%3A%2FUsers%2FZack%2Fnode_modules%2Fjasmine芯%2Flib%2Fjasmine核%2Fjasmine.js%3F3 91e45351df9ee35392d2e5cb623221a969fc009%3A1886%3A24) 在WebContent / assets / js / angular1.4.3 / angular.js:68:12 at forEach(WebContent / assets / js / angular1.4.3 / angular.js:336:20) 在loadModules(WebContent / assets / js / angular1.4.3 / angular.js:4346:5) at Object.createInjector [as injector](WebContent / assets / js / angular1.4.3 / angular.js:4272:11) at Object.workFn(WebContent / assets / js / angular1.4.3 / angular-mocks.js:2393:52) 在WebContent / assets / js / angular1.4.3 / angular.js:4385:15 Chrome 51.0.2704(Windows 10 0.0.0):执行4 of 4(1 FAILED)(0.117秒/0.074秒)
我的karma.conf.js是:
var re = /(:[a-z]\w+)(?![\s\S]*\1)/gi;
var str = 'test :one\n :one test :one test :two';
console.log(str.match(re));
//or, get rid of the inital :
console.log(str.match(re).map(function(x){return x.substr(1);}));
那么问题是什么?哪里错了? 谢谢大家帮帮我!!
答案 0 :(得分:0)
所以用简单的茉莉花测试就可以了:
'WebContent/assets/js/angular1.4.3/angular.js',
'WebContent/assets/js/jquery1.11.3/jquery.js',
'WebContent/apps/gapsweb/**/*.js',
'WebContent/apps/gapsweb/gaps.bootstrap.js',
'WebContent/apps/gapsweb/components/**/*.test.js'
但是当我写这个茉莉花测试时(它是一个自定义指令):
describe('Test Menu Directive', function () {
var element, scope;
beforeEach(function(){
module('CommonBusInfo');
inject(function ($rootScope, $compile) {
scope = $rootScope.$new();
element = angular.element('<jeep-menu application="{{codAppDirective}}"/>');
$compile(element)(scope);
scope.$digest();
})
});
it('proviamo ', function () {
console.log(111111);
var x = element.find('application');
x.triggerHandler('application');
scope.$digest();
});
});
这会收到此错误:
at WebContent/assets/js/angular1.4.3/angular.js:68:12 at forEach (WebContent/assets/js/angular1.4.3/angular.js:336:20) at loadModules (WebContent/assets/js/angular1.4.3/angular.js:4346:5) at Object.createInjector [as injector] (WebContent/assets/js/angular1.4.3/angular.js:4272:11) at Object.workFn (WebContent/assets/js/angular1.4.3/angular-mocks.js:2393:52)
%20%20%20%20原子%20Object.createInjector%20%5Bas%20injector%5D%20(HTTP%3A%2F%2Flocalhost%3A9876%2Fbase%2FWebContent%2Fassets%2Fjs%2Fangular1.4.3%2Fangular。 JS%3Fbede50a38baeba3db7a4df46069 5d01ecb437273%3A4272%3A11)%0A%20%20%20%20原子%20Object.workFn%20(HTTP%3A%2F%2Flocalhost%3A9876%2Fbase%2FWebContent%2Fassets%2Fjs%2Fangular1.4.3%2Fangular-mocks.js %3F8bc8772418adb9b2fa9517 2525c3540d23e140f4%3A2393%3A52)%0A%20%20%20%20原子%20attemptSync%20(HTTP%3A%2F%2Flocalhost%3A9876%2FC%3A%2FUsers%2FZack%2Fnode_modules%2Fjasmine芯%2Flib%2Fjasmine核%2Fjasmine.js%3F3 91e45351df9ee35392d2e5cb623221a969fc009%3A1886%3A24) Chrome 51.0.2704(Windows 10 0.0.0)测试菜单指令proviamo FAILED ReferenceError:未定义模块 在对象。 (的WebContent /应用/ gapsweb /组件/公地/菜单/ menu.directive.test.js:11:13) TypeError:无法读取属性&#39; find&#39;未定义的 在对象。 (的WebContent /应用/ gapsweb /组件/公地/菜单/ menu.directive.test.js:22:28) 日志:6969 Chrome 51.0.2704(Windows 10 0.0.0):执行2 of 2(1 FAILED)(0.014秒/0.007秒)
指令是:
angular.module("CommonBusInfo", [])
.directive("jeepMenu", ['Restangular', function(Restangular){
// Runs during compile
console.log("gapsMenuDirective");
return {
restrict : 'E',
link : function (scope, element, attrs) {
var _urlTemplate = '',_codApp = attrs.application;
if(angular.equals(_codApp,'gaps') || angular.equals(_codApp,'lirico') || angular.equals(_codApp,'topolino')){
var utente = scope.userLogged;
Restangular.one('users', utente.codUtente).one('readers', 'menu').one("commands", "menu")
.get()
.then(function (data) {
scope.loadingPercentage += 20;
scope.staticMenuTest = data.bodyResponse.dataWorkFlow.innerMenu;
_urlTemplate = 'components/commons/menu/menuDynamicView.html';
},function(err){
scope.loadingError = true;
});
scope.staticMenuTest = [];
}
else{
scope.loadingPercentage += 20;
scope.staticMenuTest = '';
}
scope.getContentUrl = function(){
return _urlTemplate;
}
},
template: '<div ng-include="getContentUrl()"></div>'
};
}])