mercredi 2 mars 2016

in karma/mocha test 'before(angular.mock.module('app'));' throw error and `beforeEach(angular.mock.module('app'));` work why?

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 ones not every time the code:

describe('timer factory', function () {

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

  it('should exist',inject(function (Timer) {
    timer = new Timer();
    should.exist(timer);
  }));
});

Aucun commentaire:

Enregistrer un commentaire