Javascript errors being swallowed? #19

Closed
opened 2011-06-19 08:23:19 +00:00 by mcmire · 5 comments
mcmire commented 2011-06-19 08:23:19 +00:00 (Migrated from github.com)

Hello sir,

First off, thanks for the helpful doc page -- it was pretty easy to get this and the Guard integration set up. However I've run into some problems. I only have one Jasmine spec, with several tests in it, but every time I run this spec using the jasmine-headless-webkit executable, I get output like "PASS: 0 tests, 0 failures, 0 secs." Now, if I use the Jasmine gem to run this spec normally, I get Javascript errors -- which is totally true, some files aren't being required properly and I'm still getting everything set up. Shouldn't jasmine-headless-webkit (or the QTWebkit wrapper which I guess is actually running the tests) propagate these errors, though? Otherwise, it's pretty frustrating trying to figure out what's going on...

Hello sir, First off, thanks for the helpful doc page -- it was pretty easy to get this and the Guard integration set up. However I've run into some problems. I only have one Jasmine spec, with several tests in it, but every time I run this spec using the jasmine-headless-webkit executable, I get output like "PASS: 0 tests, 0 failures, 0 secs." Now, if I use the Jasmine gem to run this spec normally, I get Javascript errors -- which is totally true, some files aren't being required properly and I'm still getting everything set up. Shouldn't jasmine-headless-webkit (or the QTWebkit wrapper which I guess is _actually_ running the tests) propagate these errors, though? Otherwise, it's pretty frustrating trying to figure out what's going on...
johnbintz commented 2011-06-19 15:37:42 +00:00 (Migrated from github.com)

Can you post some code that should fail, and what errors should be triggered? JS errors are passed along normally...

https://github.com/johnbintz/jasmine-headless-webkit/blob/master/ext/jasmine-webkit-specrunner/specrunner.cpp#L214

...but perhaps there is something that is being not displayed.

Can you post some code that should fail, and what errors should be triggered? JS errors are passed along normally... https://github.com/johnbintz/jasmine-headless-webkit/blob/master/ext/jasmine-webkit-specrunner/specrunner.cpp#L214 ...but perhaps there is something that is being not displayed.
mcmire commented 2011-06-19 18:09:55 +00:00 (Migrated from github.com)

Upon further inspection, it appears that I only get the "0 tests run" message if my specs are in CoffeeScript. If I'm just using straight Javascript, I get test failures.

I've made a sample project to demonstrate this: https://github.com/mcmire/jhw-issue-19. There are two commits -- you can read the commit messages, or check out the commits and try it yourself (you'll need to use bundle exec jasmine-headless-webkit as I'm pointing to HEAD in the Gemfile).

Upon further inspection, it appears that I only get the "0 tests run" message if my specs are in CoffeeScript. If I'm just using straight Javascript, I get test failures. I've made a sample project to demonstrate this: https://github.com/mcmire/jhw-issue-19. There are two commits -- you can read the commit messages, or check out the commits and try it yourself (you'll need to use `bundle exec jasmine-headless-webkit` as I'm pointing to HEAD in the Gemfile).
mcmire commented 2011-06-19 18:43:51 +00:00 (Migrated from github.com)

Okay, I went ahead and looked into it further.

There are two issues here. The first is that the code that compiles .coffee files into Javascript isn't concatenating CoffeeScript files properly -- when you have multiple CoffeeScript files, the string which results from the concatenation is invalid CoffeeScript. Using the sample project I set up, the string is this:

window.foo = 42describe "foo", ->
  it "equals 1", ->
    expect(foo).toEqual(1)

So, a simple fix would be to add either a new line or a semicolon in between each file's contents.

The second issue is that, yes, something is swallowing errors, and that something is the jasmine-headless-webkit executable (the rescue which is exiting 1). I realize you want to keep the status code, so perhaps a simple fix here would be to just print the exception details to the console?

Okay, I went ahead and looked into it further. There are two issues here. The first is that the code that compiles .coffee files into Javascript isn't concatenating CoffeeScript files properly -- when you have multiple CoffeeScript files, the string which results from the concatenation is invalid CoffeeScript. Using the sample project I set up, the string is this: ``` window.foo = 42describe "foo", -> it "equals 1", -> expect(foo).toEqual(1) ``` So, a simple fix would be to add either a new line or a semicolon in between each file's contents. The second issue is that, yes, something _is_ swallowing errors, and that something is the jasmine-headless-webkit executable (the `rescue` which is `exit`ing 1). I realize you want to keep the status code, so perhaps a simple fix here would be to just print the exception details to the console?
johnbintz commented 2011-06-19 19:09:20 +00:00 (Migrated from github.com)

Oooo, GitHub auto-links those in! Didn't know that. :) Try the latest HEAD and see if that makes a difference.

Oooo, GitHub auto-links those in! Didn't know that. :) Try the latest HEAD and see if that makes a difference.
mcmire commented 2011-06-19 20:04:54 +00:00 (Migrated from github.com)

Yup, looks like that did it, errors are showing up the console now. Thanks a bunch for the quick turnaround!

Yup, looks like that did it, errors are showing up the console now. Thanks a bunch for the quick turnaround!
Sign in to join this conversation.
No Label
bug
doc
feature
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: github-migration/jasmine-headless-webkit#19
No description provided.