Jasmine注入beforeEach被忽略

时间:2016-11-25 11:13:03

标签: angularjs jasmine karma-jasmine

使用Angular 1.5.6和angular-mocks@1.5.6

以下是我的spec文件的精简版:

describe('Controller: blahCtrl', function() {

  var blahCtrl;
  var rootScope;
  var scope;

  beforeEach(module('blahModule'));

  beforeEach(inject(function($controller, $rootScope) {
    console.log('inject beforeEach is hit'); // does not log
    rootScope = $rootScope;
    scope = $rootScope.$new();
    blahCtrl = $controller('blahCtrl as vm', {
      $scope: scope,
      $rootScope: rootScope
    });
  }));

  describe('blahMethod()', function() {
    beforeEach(function() {
      console.log('describe beforeEach is hit'); // logs
    });

    it('does something', function() {
      console.log('describe it block is hit'); // logs
    });
  });
});

我的注射beforeEach从未被击中的原因是什么?当然这应该没问题?

0 个答案:

没有答案