1
votes

I am trying to run my mocha tests with PhantomJS (through grunt-mocha). The first test throws a ReferenceError: Can't find variable: HTMLSpanElement, while the second one tests fine. In Chrome, both of these tests pass. Any ideas on why this might not be working?

This throws 'ReferenceError: Can't find variable: HTMLSpanElement':

it 'Instance of Span', ->
    $el = $('<span></span>')
    expect($el[0]).to.be.an.instanceof(HTMLSpanElement);

This test passes:

it 'Instance of Element', ->
    $el = $('<span></span>')
    expect($el[0]).to.be.an.instanceof(HTMLElement);
1

1 Answers

1
votes

PhantomJS does not implement HTMLSpanElement.

phantomjs> HTMLSpanElement
Can't find variable: HTMLSpanElement
phantomjs> HTMLAnchorElement
{
   "prototype": {
      "getParameter": "[Function]"
   }
}

In reality, PhantomJS might be able to implement it, I think the version of webkit it uses depends on the libraries it is compiled against. How to compile it against a different version of webkit than the default and whether it will work or not, I have no idea.