【问题标题】:PhantomJS Mocha 'Can't find variable: HTMLSpanElement'PhantomJS Mocha'找不到变量:HTMLSpanElement'
【发布时间】:2013-07-19 19:27:20
【问题描述】:

我正在尝试使用 PhantomJS(通过 grunt-mocha)运行我的 mocha 测试。第一个测试抛出一个ReferenceError: Can't find variable: HTMLSpanElement,而第二个测试很好。在 Chrome 中,这两个测试都通过了。关于为什么这可能不起作用的任何想法?

这会抛出'ReferenceError: Can't find variable: HTMLSpanElement':

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

此测试通过:

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

【问题讨论】:

    标签: phantomjs mocha.js


    【解决方案1】:

    PhantomJS 没有实现HTMLSpanElement

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

    实际上,PhantomJS 可能能够实现它,我认为它使用的 webkit 版本取决于它编译的库。如何针对与默认版本不同的 webkit 进行编译,以及它是否可以工作,我不知道。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-24
      • 1970-01-01
      • 2018-04-11
      • 2015-05-26
      • 1970-01-01
      • 1970-01-01
      • 2016-10-17
      相关资源
      最近更新 更多