title: stubbing `window.location.reload` for unit tests - "Some of your tests did a full page reload!"
body: <p>I have this in a controller:</p>
  
  <pre><code>   $scope.foo = function(){
        return RolesService.remove({
          data: role
        })
        .then(function (v) {
          if (!(v &amp;&amp; v.cdtError)) {
            $window.location.reload();
          }
        });
      }
  </code></pre>
  
  <p><code>$window</code> is injected into the controller</p>
  
  <p>and then in my unit test:</p>
  
  <pre><code> let $window = {location: {reload: sinon.spy()}};
  
    module(function ($provide) {
      $provide.value('$window', $window);
      $window.onbeforeunload = sinon.spy();
    });
  </code></pre>
  
  <p>the above stub doesn't seem to do anything, because I still get this error:</p>
  
  <blockquote>
    <p>Some of your tests did a full page reload!</p>
  </blockquote>
  
  <p>How can I stub <code>window.location.reload</code> so that this doesn't happen?</p>
  
  <p>I see some stuff on the Karma Github issue tracker for this, but I can't find an answer.</p>