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

Cannot decode JSON from PhantomJS runner: can't convert nil into String #70

Closed
thbar opened this issue Jul 19, 2012 · 3 comments
Closed

Comments

@thbar
Copy link

thbar commented Jul 19, 2012

I noticed by experimenting that if you provide a CoffeeScript class instead of a string as a first param of describe (although it's not supposed to be supported! But I'm new to this, so please bear with me), going to the browser at /jasmine will happily report failures properly (just with an empty description), while guard-jasmine will choke on the JSON parsing, and only when errors happen.

Here's an example json (trimmed down):

{
    "passed": false, 
    "stats": {
        "failures": 1, 
        "specs": 7, 
        "time": 0.017
    }, 
    "suites": [
        {
            ## missing description key here, which I suspect leads to the exception ##
            "passed": false, 
            "specs": [
                {
                    "description": "excludes that", 
                    "messages": [
                        "Expected 5 to equal 4."
                    ], 
                    "passed": false
                }
            ], 
            "suites": []
        }, 
        {
            "description": "A string is passed here and this one works ok", 
            "passed": true, 
            "specs": [
            ...
            ], 
            "suites": []
        }
    ]
}

This only happens when you have failures in the specs.

Suggestion: we could maybe default to an empty description instead of this exception, to be consistent with the behaviour seen in the browser?

What do you think?

@netzpirat
Copy link
Contributor

Just did a quick check in two projects of mine that are using guard-jasmine and if I use a CoffeeScript class as description in the describe function, then the Jasmine HTML runner fails with 'Uncaught Error: NOT_FOUND_ERR: DOM Exception 8' and the Guard Jasmine runner fails with a timeout ('ERROR: An error occurred: Timeout waiting for the Jasmine test results!').

Even when it would behave like you've described, I'm not sure if it's a good idea to catch the missing description, because it's a wrong usage of Jasmine. But on the other side, it doesn't harm and may help, so why not?

@thbar
Copy link
Author

thbar commented Jul 19, 2012

Hey - that was quick :)

But on the other side, it doesn't harm and may help, so why not?

My thoughts exactly (plus it provides a consistent experience with what going to /jasmine to see the runner provides).

Thanks for your patch!

@thbar
Copy link
Author

thbar commented Jul 19, 2012

Woops - I read your comment too quickly on the html runner! Unsure why the difference in behaviour; but yes I guess it doesn't matter much. 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