LoginSignup
0
0

More than 5 years have passed since last update.

[angular] mocking $window

Last updated at Posted at 2014-12-02

injectでテスト対象を取得する前に$provideを使ってモックを登録しておく.



describe("HowToMock$Window", function(){

  beforeEach(function(){
     // we need to setup $window mock before inject()
     mock(function($provide){
       $provide.factory("$window", function(){
         var $window = {};
         return $window;
       });
     });
    // get service/controller which depends on $window
    inject(function(someService){

    });

  });

});

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0