Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify "Some of your tests did a full page reload!" #1101

Open
Wilfred opened this issue Jun 13, 2014 · 45 comments
Open

Clarify "Some of your tests did a full page reload!" #1101

Wilfred opened this issue Jun 13, 2014 · 45 comments

Comments

@Wilfred
Copy link

Wilfred commented Jun 13, 2014

If I'm debugging some hairy code I sometimes see this error. It would be really helpful if Karma said what URL my tests tried to navigate to.

@davidlinse
Copy link

👍

@ruffrey
Copy link

ruffrey commented Aug 4, 2014

+1 please

@fabien0102
Copy link

+1

@maksimr
Copy link
Contributor

maksimr commented Aug 13, 2014

This is not so simple, I think.

  1. When in your code called location.reload() URL is not so helpful.
  2. When you call location = 'test' we can not get new location in beforeunload callback

How described in comment more helpful will be have name of test which cause reload.
But I think it adapter issue also, because adapter has more information about tests.

Thanks!

@matteofigus
Copy link

+1, even the test would be great!

@n1k0
Copy link

n1k0 commented Feb 5, 2015

+100000^100000 this is turning me crazy.

@ajbogh
Copy link

ajbogh commented Feb 19, 2015

+1 - I have over 1700 tests that run on a very large app. Since the error doesn't say which test did the reload, or what line of code caused the reload, I'm going to have to go through all of my spec files and ddescribe every file until I find the file that's causing the problem. Once there I'll have to iit every test until I find the culprit. It would be much better if Karma could just say which test name caused the problem, or even go so far as to show the line in the code.

@Wilfred
Copy link
Author

Wilfred commented Feb 19, 2015

@maksimr would calling console.trace() help?

@chfw
Copy link

chfw commented Mar 30, 2015

+1. It would help if Karma could tell which test case did a full page reload.

@surajk
Copy link

surajk commented Apr 8, 2015

+1 please

@ghost
Copy link

ghost commented May 8, 2015

+1. I am encountering this on unit tests that are never injecting the $window or $location object, and not sure how page reloads could be happening.

It is very rare and I cannot reproduce consistently unfortunately. More info in the error would really help out.

@jseto
Copy link

jseto commented May 10, 2015

@trov-codystebbins
I have exactly the same problem as you. It happens only in autoWatch mode when reloading after an error when testing directives but NOT injecting $location nor $window.

To work around, I exit from karma and run again. Always get rid of the message with no further action. but anoying... :(

@pablo-zocdoc
Copy link

+1

@dineshWizni
Copy link

Hi I am facing the same issue , at one place I have window.location.href in my code (when I do not find something stored in the cookie , I redirect it to some page) , but it has nothing to do with my test cases. And I am getting this error. Any help plzzz?

@jywu
Copy link

jywu commented Jul 10, 2015

Is this being fixed? I'm also having the error even though I do not reload the page in my unit tests (I do have window.location.replace(URL) in my application.) Any help?

@hulufei
Copy link

hulufei commented Jul 10, 2015

+1

@bensampaio
Copy link

I'm also experiencing this behaviour and I'm quite sure I have no reloads on my tests.

I don't know if this could be the problem but I'm using webpack and babel alongside karma. When I change any spec file I always get the full page reload error, but all other files are ok (I mean, Karma detects the changes and run the tests again without any reload).

I have to constantly restart karma which is really not productive... Any ideas?

@mkolodny
Copy link

+1

@booleanbetrayal
Copy link

+1

@Furizaa
Copy link

Furizaa commented Jul 25, 2015

I've gotten this error on every change to one simple test expect(true).toBe(true); using webpack and babel. In the end I got this working by using exactly the same setup the react-router project is using (versions of karma-* packages, karma.conf). No problems so far.

https:/rackt/react-router/blob/master/package.json#L41
https:/rackt/react-router/blob/master/karma.conf.js

@kylechadha
Copy link

+1

@mqklin
Copy link

mqklin commented Aug 28, 2015

+1
Try to reduce amount of describe sections. I don't know why, but it's work for me.

@gabrieledarrigo
Copy link

+1

1 similar comment
@ikr0m
Copy link

ikr0m commented Sep 12, 2015

+1

@VictorQueiroz
Copy link

I was on the same issue. Then I removed the window event "beforeunload" and everything is running just fine now...

@nbrustein
Copy link

@VictorQueiroz I tried removing all of our beforeunload handling but am still seeing the issue. Then again, I guess this ticket is less about preventing the issue and more about being specific about where it's coming from anyway.

Thanks for the suggestion, anyway.

@haibei-victor-wu
Copy link

+1 does someone know the problem

@mqklin
Copy link

mqklin commented Sep 26, 2015

@haibei-victor-wu, try to reduce the number of describe sections.

@JamieMason
Copy link

I hope this helps someone, you can track down causes of this issue with the following steps.

  1. Run your app with the following code included before anything else and DevTools (Chrome, in this case) open.
console.profile('cause of reload');

window.addEventListener('beforeunload', function() {
    console.profileEnd('cause of reload');
    debugger;
});

If the reload you're looking for happens, you should be taken to the "Sources" view of Chrome Devtools with the app paused at the debugger line.

  1. Navigate to "Profiles" tab and choose the "Charts" view.
  2. Command+F and search for "location".
  3. Use the up and down arrows in the search box to jump to the last occuring matches for that phrase.
  4. Hit enter in the search field to jump to the match.
  5. Look back through the call stack for code you recognise.

@MichaelFBA
Copy link

+1 this is so painful atm

@madstt
Copy link

madstt commented Oct 7, 2015

I fought the same issue for some time. I came up with the following solution.

I your tests, before you inject anything, create a $window object and use $provide.value() to override the built-in $window object, like this:

beforeEach(function () {

  module('app');

  $window = {location: {reload: sinon.spy()}};

  module(function($provide) {
    $provide.value('$window', $window);
  });

  inject(function (...) {...} )

});

Instead of sinon.spy() you could use a variable of a sinon spy and use it in your assertions.

I hope this can help someone else.

@felix-d
Copy link

felix-d commented Oct 8, 2015

+1

@nebulou5
Copy link
Contributor

Can someone confirm my thinking on this in this PR: #1648 This should at least address the issue of page reloads happening when a user isn't even messing with the location within a spec or dependency.

Refer to SHA: 471e3a8 for initial implementation of 'reloadingContext' flag and this stackoverflow post: http://stackoverflow.com/questions/29352578/some-of-your-tests-did-a-full-page-reload-error-when-running-jasmine-tests

@nebulou5
Copy link
Contributor

To anyone who is getting this issue lately when your specs don't even mess with the location, it seems to be an issue with jasmine-core... refer to these issues: Refer to jasmine/jasmine#366 and jasmine/jasmine#945

@CaptainMat
Copy link

Any updates on this issue ? or workaround ? Jasmine issues are still open and the problem is still happening in karma 0.13.14.

@stefan-dimitrov
Copy link

+1

@timasjov
Copy link

Better error message will provided much more value.
As well I am getting this error when doing $window.location.reload(); 👎

@JamieMason
Copy link

Maybe I misunderstand @timasjov, but isn't $window.location.reload(); supposed to do a full page reload? You will probably want to mock that in your test.

joeyparrish added a commit to shaka-project/shaka-player that referenced this issue Nov 26, 2015
Avoid karma v0.13.15, which has a bug that prevents our new
integration tests from running correctly on Chrome.
(See karma-runner/karma#1101)

Change-Id: Ia81410b1184ddca3a703d71cd923d4ec0ae5eefc
@tkehayov
Copy link

+1

3 similar comments
@ppalladino
Copy link

+1

@MarcoDeJong
Copy link

+1

@csvan
Copy link

csvan commented Dec 9, 2015

+1

@dignifiedquire
Copy link
Member

Please refrain from +1 this issue, I know it's important but there is no straightforward way to actually fix this in karma, as the architecture currently does not allow for this.

@lukaselmer
Copy link

+1

@karma-runner karma-runner locked and limited conversation to collaborators Dec 29, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests