似乎我的Jasmine测试忽略了我的beforeEach函数(最后一个)。如您所见,我有一些控制台日志。我基本上得到了:
DESCRIBE
控制器
未定义
INJECTING ...没有被记录 - 这很重要,因为它是负责模拟我的服务的测试的一部分,当然返回undefined因为它跳过了我的beforeEach。
describe('Moment Controller', function() {
var $scope, $controller, momentsService, $ionicContentBanner, core, components, $q, $ionicPopup;
beforeEach(module('app'));
beforeEach(module('core'));
beforeEach(module('components'));
beforeEach(module('constants'));
console.log("DESCRIBE");
beforeEach(inject(function(_$controller_, $rootScope, _momentsService_, _$ionicContentBanner_, _core_, _components_, _$q_, _$ionicPopup_) {
console.log("INJECTING..."); //<--- IGNORED!
$scope = $rootScope.$new();
momentsService = _momentsService_;
$ionicContentBanner = _$ionicContentBanner_;
core = _core_;
components = _components_;
$q = _$q_;
$ionicPopup = _$ionicPopup_;
spyOn(momentsService, 'initializeView');
$controller = _$controller_('MomentsController', {
momentsService: momentsService,
$scope: $scope,
$ionicContentBanner: $ionicContentBanner,
core: core,
component: components,
$q: $q,
$ionicPopup: $ionicPopup
});
}));
it('should initialize', function() {
console.log("CONTROLLER");
console.log(momentsService);
});
});
有谁知道这里发生了什么?
感谢。