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

Already on GitHub? Sign in to your account

Strange Issue in Phantom Environment #112

machineghost opened this Issue Feb 3, 2013 · 5 comments


None yet
4 participants

I'm using Grunt/Phantom to run Jasmine tests, and jasmine-jQuery seems like the perfect library for doing jQuery assertions in them. There's only one problem: when I try and use the Jasmin-JQuery expect/toBeI get the following error:

TypeError: 'undefined' is not a function (evaluating 'haystack.indexOf(needle)')
TypeError: 'undefined' is not an object (evaluating 'this.views.suites')

Where MyTests.js:33 is:

expect($td).toContain('.error:contains("test message")');

Now for the really strange part: if I add:


just before that line, everything works smoothly (I discovered this by trying to console.log(jasmine.JQuery)).

This makes zero sense to me; calling a variable should in no way impact whether the assertions work or not. So my question is, have you ever seen behavior like this before, and if so any hints on resolving it?


travisjeffery commented Apr 28, 2013

Did you ever figure this out?

I've never seen this before. Usually people are pretty good about commenting for problems they've seen before so I guess nobody else has seen this one before either.

Nope, sorry; I just wound up abandoning Jasmine.

Do you have a describe call inside and it call?

I don't think so, but I suppose I might have. However, as I mentioned I'm using Mocha now, so if you can't reproduce this issue (and I'm certainly not going to) then I think this is a dead issue. Sorry I can't be more helpful.

I also ran into this. It appears to be due to async things. In my case it was due to an issue with require.js and how things were loaded. This would often fail:

require ['athing'], (athing) ->
  # All the tests ...

This seems to solve the problem, but is not optimal.

define 'a set of tests', ->
  athing = null

  requrires = ->
    require ['athing'], (obj) ->
      athing = obj

  conditions = ->
    athing isnt null

  beforeEach ->
    waitFor conditions, "athing to load", 5000

  afterEach ->
    athing = null

While the second example works, I would prefer to do my requires at the top of the file. The error is not consistent and occurs rarely when requiring some modules and consistent when requiring others. Not sure this is a jasmine-jquery problem, but thought it worth while to document my findings related to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment