【问题标题】:All tests fail in Web Component Tester for FirefoxFirefox 的 Web 组件测试器中的所有测试均失败
【发布时间】:2015-07-15 16:15:01
【问题描述】:

创建 Polymer Starter Kit 的干净副本后,使用 Web 组件测试器(“测试”Gulp 任务)运行测试会导致 Firefox 中的所有测试都失败。

测试在 Chrome 和 IE 中运行良好。

错误是:

firefox 39               ✖ my-greeting-basic.html
  Timed out loading http://localhost:2000/components/polymer-starter/my-greeting-basic.html?
    <unknown> at                          done at /components/mocha/mocha.js:1846:0
    <unknown> at        Runner.prototype.run/< at /components/mocha/mocha.js:5213:0
    <unknown> at   EventEmitter.prototype.emit at /components/mocha/mocha.js:616:0
    <unknown> at                       start/< at /components/mocha/mocha.js:5203:0
    <unknown> at     Runner.prototype.runSuite at /components/mocha/mocha.js:5103:0
    <unknown> at                         start at /components/mocha/mocha.js:5201:0
    <unknown> at          Runner.prototype.run at /components/mocha/mocha.js:5226:0
    <unknown> at           Mocha.prototype.run at /components/mocha/mocha.js:1849:0
    <unknown> at                             g at /bower_components/webcomponentsjs/webcomponents.min.js:11:0
    <unknown> at                             w at /bower_components/webcomponentsjs/webcomponents.min.js:11:0
    <unknown> at                             f at /bower_components/webcomponentsjs/webcomponents.min.js:11:0
    <unknown> at                             p at /bower_components/webcomponentsjs/webcomponents.min.js:11:0
404 GET /components/polymer-starter/my-list-basic.html
firefox 39               ✖ my-list-basic.html
  Timed out loading http://localhost:2000/components/polymer-starter/my-list-basic.html?
firefox 39               Tests failed: 2 failed tests
Test run ended in failure: 2 failed tests
Process terminated with code 1. 

在浏览器中,对测试套件的调用会导致 404。

【问题讨论】:

  • 要让 Karma 在 Windows 上的浏览​​器上正常工作,您需要添加几个系统变量,这些变量是否已为 firefox 设置:setx FIREFOX_BIN "C:\Program Files (x86)\Mozilla火狐\firefox.exe" /M
  • Firefox 启动正常,但对 html 测试套件的请求导致 404。
  • 我遇到了同样的问题。从直接下载或使用yo polymer 设置新项目开始,我得到与上述相同的错误。再深入一点,我发现如果我可以抓取 URL 并将其放入弹出的 Chrome 或 IE 实例中,那么测试将通过,但如果我将其放入任一浏览器的现有实例中(即没有 Selenium 扩展)然后它以同样的方式失败。我在想 FF 没有激活扩展 - 虽然它正在安装。还在挖。

标签: polymer web-component-tester polymer-starter-kit


【解决方案1】:

问题是,当 Windows 中的 Firefox 在路径中看到反斜杠时,它会搞砸。我花了很长时间才弄明白,但我已经在相关项目上打开了一张票,并提交了一个拉取请求以寻求我想出的修复。

如果您不耐烦,可以导航到 &lt;your project&gt;/node_modules/web_component_tester/runner/webserver.js 并将以下内容放在第 80 行之前(options.webserver.webRunnerContent = INDEX_TEMPLATE(options)

options.suites = options.suites.map(function (cv) {
  return cv.replace(/\\/g,'/');
})

这会将路径中的反斜杠更改为 Firefox 没有问题的正斜杠。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-18
    • 1970-01-01
    • 2020-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多