【问题标题】:YUI test error: window.getYUITestResults()YUI 测试错误:window.getYUITestResults()
【发布时间】:2014-10-03 13:40:04
【问题描述】:

当我使用 grover 通过 PhantomJS 运行 YUI 测试时出现错误:

TypeError: 'undefined' 不是函数(评估 'window.getYUITestResults()')

我发现这个错误是因为我使用 location.reload() 而 PhantomJS 有这个问题。

【问题讨论】:

    标签: javascript unit-testing phantomjs yui grover


    【解决方案1】:

    所以这里是解决方案:

    if (window['phantom'] || window['_phantom']) return;
    location.reload();
    
    • window['phantom'] - 表示存在 PhantomJS,但是当您使用 grover 时,此属性不存在 :(
    • window['_phantom'] - 使用 grover 表示存在 PhantomJS

    使用这个简单的解决方案,您可以随意跳过代码,祝您好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多