【问题标题】:Travis CI builds failing - Phantom JS timing out with MochaTravis CI 构建失败 - Mocha 导致 Phantom JS 超时
【发布时间】:2015-06-03 02:18:31
【问题描述】:

我正在使用 Travis CI 为 Typescript 项目自动进行单元测试。一切都在本地运行良好,但在 Travis 上,最后会弹出以下错误消息:

Running "mocha:test" (mocha) task
Testing: Tests/tests.html
Warning: PhantomJS timed out, possibly due to a missing Mocha run() call. Use --force to continue.

https://travis-ci.org/FullScreenShenanigans/ChangeLinr/builds/58349376

.travis.yml:

language: node_js

node_js:
  - "0.12"

before_script: 
  npm install grunt grunt-cli grunt-contrib-copy grunt-contrib-uglify grunt-contrib-clean grunt-zip

script:
  grunt

我在这里做错了吗?

【问题讨论】:

    标签: typescript phantomjs mocha.js travis-ci


    【解决方案1】:

    我在 Travis 上遇到了完全相同的错误。 这是我的新工作 .travis.yml:

    sudo: false
    language: node_js
    node_js:
      - '0.12'
    before_script:
      - npm install -g grunt-cli bower
      - bower install
    

    就我而言,我拥有您在.travis.yml 中列出的所有 grunt 包(grunt-cli 除外),在我的package.json 中列为devDependencies。 (我认为这更可取,这样这些依赖项只会在一个地方被跟踪。)

    我也没有你的script: grunt 部分,但这只是因为我从我的package.json 调用grunt test,即:

    "scripts": {
      "test": "grunt test"
    },
    

    来自我的 bower.json 的相关摘录:

    "devDependencies": {
      "chai": "~2.3.0",
      "mocha": "~2.1.0"
    },
    

    由于我尚未确定的原因,我发现我会在 Mocha >=2.2.0 时得到那些 PhantomJS 超时错误(我专门测试了 2.2.0 和 2.2.4),所以我将 Mocha 保留为 2.1.x。

    如果有帮助,here's an actual commit 实现了上述所有功能。

    【讨论】:

    • 非常有趣!感谢您的回答,尽管我最终以不同的方式解决了它。无法跟上 Mocha 版本的更新将是一个杀手。
    【解决方案2】:

    我最终通过转到grunt-mocha 解决了这个问题。问题仍未解决,但由于 grunt-mocha 是专门为在 grunt 中运行 mocha 而设计的,因此使用它似乎是合理的。

    相关提交:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-03
      • 1970-01-01
      • 1970-01-01
      • 2013-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多