Some of your tests did a full page reload - error when running Jasmine tests Some of your tests did a full page reload - error when running Jasmine tests angularjs angularjs

Some of your tests did a full page reload - error when running Jasmine tests


In my case the problem was that in my source code I had code directly setting the href on the location object, like window.location.href = 'somewhere';

In my specs I set up a onbeforeunload listener that just returns a string instead of allowing the redirect to take place:

beforeAll(() => {  window.onbeforeunload = () => 'Oh no!';});


Make sure that your tests are properly isolating all modules under test with mocks/spies. The behavior you are seeing says to me that your tests are not truly running in isolation - they are changing some state somewhere that will trigger a reload.


I suppose you are using window.location somewhere in your targeted code. In order to pass it just create a spy for the window.onbeforeunload

Example:

window.onbeforeunload = jasmine.createSpy();

Or even better use $window instead, and this will not happen.