0

so I start to use karma/mocha lib to test webpack/angular app

and when I write before(angular.mock.module('app')); it throw error

FAILED timer factory "before all" hook: workFn
debug.html:38 TypeError: Cannot read property '$injector' of null
at Context.workFn (base/node_modules/angular-mocks/angular-mocks.js:2653:22)

and when using beforeEach(angular.mock.module('app')); it work fine.

why??

I think I should init the module one not every test

the code:

describe('timer factory', function () {

  beforeEach(angular.mock.module('app'));

  it('should exist',inject(function (Timer) {
    timer = new Timer();
    should.exist(timer);
  }));
});
pery mimon
  • 7,713
  • 6
  • 52
  • 57
  • i thik, will be step for process, so beforeEach could be loaded at first initializacion of test, and before at second, so angular will be required – Álvaro Touzón Mar 02 '16 at 12:29
  • here same quesrtion http://stackoverflow.com/questions/21418580/what-is-the-difference-between-before-and-beforeeach – Álvaro Touzón Mar 02 '16 at 12:30
  • that is nice qustion/answer but I know the diffrent between `before` and `beforeEach` . I just not understand way before fail – pery mimon Mar 03 '16 at 13:12

0 Answers0