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

ERROR: Cannot decode JSON from PhantomJS runner: 710: unexpected token at '{"error":"Timeout requesting Jasmine test runner!"} ' #5

Closed
laripk opened this issue Oct 27, 2011 · 6 comments

Comments

@laripk
Copy link

laripk commented Oct 27, 2011

I've gotten this error several times today. Here are a couple examples of the full error message: https://gist.github.com/1321074

It's complaining because it's getting two JSON objects when it's expecting one.

(I haven't figured out why it's sending both back. That may be a separate issue.)

@laripk
Copy link
Author

laripk commented Oct 28, 2011

I figured out why it's timing out:

I recently added a test for the creation of a 3rd-party object that requires the pre-existence of the DOM object it attaches to. I got this to pass under rake jasmine:ci on sinatra by adding a document.write at the beginning of my spec to create said DOM object. (I'm in the middle of moving my project from sinatra to rails 3.1.)

That document.write appears to be messing up what you're looking for to signal the tests being done.

@netzpirat
Copy link
Contributor

What version are you using? The problem is that the timeout occurs in the middle of sending the result back. Prior to version 0.7.2 there was a timeout bug that restricted the overall waiting time (request specs, running specs and return result) to 1 second. This has been resolved and an additional timeout option has been added. The default is 10 seconds.

@laripk
Copy link
Author

laripk commented Oct 28, 2011

My Gemfile.lock says I'm using guard-jasmine (0.7.2).

I found the :timeout option and tried increasing it - that just made me wait longer until I got the same message.

This test reproduces the problem: https://gist.github.com/1322112

I'm sure the document.write is just a bad kluge, I'm new to serious javascript coding; it just happened to work under my previous autotest setup. I'll be looking into alternate ways to create the DOM object my 3rd-party control is looking for.

@laripk
Copy link
Author

laripk commented Oct 28, 2011

I was able to get rid of the timeout problem by changing the document.write to $('body').append(...)

When I ran the test in my browser (jasminerice (0.0.7), also in use by guard-jasmine) I noticed that the document.write somehow clobbered the page and then the DOM elements still didn't show up (Chrome's Inspect Element/Developer Tools).

@netzpirat
Copy link
Contributor

You cannot use document.write once the document has completed loading. If you do, the browser will open a new document that replaces the current. Since the new document has no Jasmine runner, guard-jasmine will continue to wait for the Jasmine runner to finish until it reaches the timeout.

So you can't use document.write with Jasmine, use jQuery DOM manupulation helpers instead.

@laripk
Copy link
Author

laripk commented Oct 31, 2011

Ah. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants