AngularJS module .run order and e2e mocks -


i working on e2e tests angularjs.

i have implemented $httpbackend ngmocke2e.

this works well, in instances http requests being made before mocks have been set up.

the mock set as:

  angular.module('mock', ['ngmocke2e']).      run(function($httpbackend) {        $httpbackend.whenpost('/path1').respond({ exampleresponse: 'valid' });       $httpbackend.whenpost('/path2').respond({ exampleresponse: 'valid' }); 

and used below:

angular.module('application', ['firstdependency', 'mock', 'thirddependency']); 

however firstdependency , thirddependency can make http requests happen before mock .run() block has been executed. results in request errors.

am setting mocks correctly? best way ensure mocks loaded in right order?

this doc says:

dependencies:   modules can list other modules dependencies. depending on module implies required module needs loaded before requiring module loaded. in other words configuration blocks of required modules execute before configuration blocks of requiring module. same true run blocks. each module can loaded once, if multiple other modules require it. 

however doesn't first execute config blocks modules (dependencies first) , then execute other blocks in row each module in turn. illustration of take @ jsfiddle:

http://jsfiddle.net/9fjnz/2/


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -