Open kcz opened 12 years ago
I have no problems running your test on Mac. There are some issues with phantomJS v1.5 on windows too. I have no idea what we can do about it, though.
I'm getting the same error, I'm on 12.04 with PhantomJS 1.5. I can run the qunit task fine though.
Same error on OS X with phantomjs 1.5
@axelhzf could you provide me with a barebones setup that fails? I'm on OS X as well and have so far not encountered any problems.
It was a problem of my test runner configuration, I was using a HtmlReporter. When I delete this reporter it worked. My final configuration is:
<script type="text/javascript">
jasmine.getEnv().execute();
</script>
I ran kcz's test project on OSX Lion, and I get the same error. A project I've been working on is showing the same results.
@mattd what version of PhantomJS are you using? 1.5? I'm still on v1.4.1 and have no problems. This is a really unfortunate situation. Something changed from v1.4.x to v1.5, but I have no idea what. Could be PhantomJS is WAI and my code simply benefits from a previous PhantomJS bug - or a new bug was introduced in PhantomJS. It's however very hard to find out what is going wrong since there's a whole stack of tech involved: grunt, phantomjs, jasmine, my plugin, and a bunch of other node modules.
@ariya is there some way we could join forces on this and find out what's going wrong? I can mail you more specifics about how my grunt plugin uses phantomjs
Hey creynders, thanks for your work on this and it's good to see you on the interwebs again. I noticed on my setup with Windows 7 that Phantom 1.4 and 1.5 both time out but 1.3 works. Using grunt-mocha all three time out. The tasks are so similar I don't know why I see different results. Sorry, I don't have an answer yet either.
@creynders Yeah, the size of the stack is what had me scratching my head.
So I finally got my setup working after many hours. My notes:
Thanks so much for writing this task - I initially thought I'd have to write it myself. ;)
For reference, the bug report. http://code.google.com/p/phantomjs/issues/detail?id=583
@mattd wow, thanks a lot for the hard work! I'll keep an eye on your bug report and see if there is something I do have to do.
@kcz @mattd @axelhzf @Aaronius @Jontyy Have you guys tried PhantomJS v1.6 ? With the Grunt Qunit plugin there were similar problems and I just had confirmation from someone that they were solved by updating.
@creynders , thanks for your reminder. But i've got the same error with PhantomJS v1.6 in Ubuntu 10.04. How about other guys?
Same problem here, PhantomJS 1.5.1, Ubuntu 12.04. Would love to figure this out.
I have the same problem here in ubuntu. My project work fine in Mac OS but when i run the grunt-jasmine task it always shows me a time out error. :0
I get timeout with phantomjs 1.6 on mac os
Running "jasmine:all" (jasmine) task Running specs for runner.html
Aborted due to warnings.
I had this same issue with both Jasmine and Mocha Grunt tasks using PhantomJS 1.6.1.
In your specrunner.html (or whatever you have it named), include this javascript fle: https://github.com/creynders/grunt-jasmine-task/blob/master/tasks/jasmine/jasmine-helper.js
Example:
<head>
<!-- Beginning of specrunner.html etc.... -->
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.2.0/jasmine-html.js"></script>
<script type="text/javascript" src="../node_modules/grunt-jasmine-task/tasks/jasmine/jasmine-helper.js"></script>
<!-- Now include spec files here... -->
</head>
<!-- The rest of the document.... -->
It completely eliminated all issues for me!
OMG, you right, this absolutely solved my problem in ubuntu 12.04 ! thank you so much !
Sorry, it doesn't work to me in ubuntu 10.04, using nodejs 0.6.15 and phantomjs 1.6.0 !
@nhunzaker , thanks so much. You are right. "jasmine-helper.js" is the final solution. It seems to me phantomjs 1.6.0 is buggy. When I upgraded to 1.6.1, it works on both mac and ubuntu 10.04. In the file "jasmine-helper.js", "alert" of function sendMessage is the key point.
@chchrist , Timeout error using requireJS doesn't matter with grunt-jasmine-task. It comes from the same reason discussed above.
There is a demo with requireJS working well on mac lion and ubuntu 10.04. http://kcz.me/test/grunt-jasmine-requirejs.zip
Don't forget to upgrade phantomjs to 1.6.1 !
I'm re-opening this, since I'm not convinced this is the definite solution. I'm afraid i won't be able to fix this 100% until this comes through: http://code.google.com/p/phantomjs/issues/detail?id=539
Maybe I should add @nhunzaker 's solution (thanks for that BTW !!!) to the README though.
@creynders I think that would be very helpful! It definitely needs to be way more prominent than the line in the docs for grunt-mocha!
Hmmm, unfortunately this cripples manually run spec runner files. Since the task uses alerts to relay the events from the sandboxed specrunner to grunt, all these alerts are thrown when it's run manually. I suppose it's the same with the grunt-mocha task. Damn, at the moment I don't have the time to think this through to make this less hackish.
any update on this issue?
I got the same error Running "jasmine:all" (jasmine) task Running specs for index.html
Aborted due to warnings.
Using Mac OS X 10.6.8 + phantomjs-1.6.1 + nhunzaker's solution.
I have a bug that I believe to be similar to this. My SpecRunner.html references a reporter in addition to the helper. When it does, the tests are run before grunt-jasmine-task's reporter is able to pick them up. If I omit my own Reporter, everything works fine.
I found a way to solve this, by injecting the helper on the DOMContentLoaded event. Here's a nice workaround to make phantomjs support it: https://gist.github.com/2475509
@cburgmer that seems like a really clever solution! One thing I don't understand however is why you use an eval to run the function, wouldn't this work with a direct call to a function too, since the onConsoleMessage handler isn't sandboxed?
Hi, I didn't look at the code for too long. However the idea is neat and it does work. I could get the task's own reporter to be added before the tests would actually start.
My issue is/was that grunt-jasmine-task would only run about half of my tests, as the test run was already underway when the reporter was added. You might want to open another bug report for that.
Could you guys checkout the code in the WIP branch?
It should solve the timeout problems. I have a hard time testing it, since I haven't encountered the problem myself yet. But I feel quite confident this is the solution.
If it is, thank you so much @cburgmer !!! My solution is based on yours, although - as I wrote - there's no need to use eval
you can call the injecting code directly.
Hi folks - I'm having the problem as well. I'm unclear if you fixed it. Could you post your specrunner file?
I've been working to fix a similar problem related to the Warning: PhantomJS timed out, possibly due to an unfinished async spec. Use --force to continue
error.
I'd thought this was due the Jasmine async tests we had been using combined with PhantomJS / Grunt / grunt-contrib-jasmine. But after a LOT of time and investigation I found it was related to the way some of our tests were being cleaned up:
afterEach(function () {
$body.empty();
});
In this instance we were emptying all the elements injected into the DOM for the test. But this doesn't unbind all the JS code which lingers in the background and causes PhantomJS to eventually timeout. This blocked further Grunt tasks from running reports.
This is the better technique:
afterEach(function () {
$element.remove();
$nav.remove();
});
Elements added to the DOM should be removed individually to ensure all the JS associated with them is properly removed and cleaned up, ready for the next spec.
This meant we could have a large stack of 77 specs complete without PhantomJS timing out.
When I try to run grunt jasmine, it failed, due to a timeout, in Ubuntu 10.04 with PhantomJS 1.5. But the same project worked well in my Mac 10.7.3.
The error message is as follows:
In order to debug, I replaced my project with jasmine demo from official site. The same phenomenon happened again. Here is the minimized project to indicate problem: http://kcz.me/test/grunt-jasmine.zip
Maybe the reason comes from phantomJS version. Is there anyone know where I can download PhantomJS 1.3 since that there is no download link in googlecode.
Thanks.