【问题标题】:Running Mocha tests on Bamboo在 Bamboo 上运行 Mocha 测试
【发布时间】:2018-01-11 08:44:11
【问题描述】:

我正在尝试在 Bamboo 中为 Node.js 项目运行测试套件,但 Bamboo 无法识别我的测试套件

这是 Nodej.js 项目的结构:

Project
    app
        controller
        model
        routes
        services
    node_modules
    test
        controller
            test1.js
            //more tests
        model
            test1.js
            //more tests
        routes
            test1.js
            //more tests
        services
            test1.js
            //more tests
    package.json
    //other files 

我的 package.json 看起来像这样:

 {
  "dependencies": {
      //dependencies  
  },
  "devDependencies": {
    "chai": "^4.1.0",
    "growl": "^1.8.1",
    "grunt-generate": "^0.3.2",
    "gulp": "^3.9.0",
    "gulp-concat": "^2.6.0",
    "gulp-ng-annotate": "^2.0.0",
    "gulp-uglify": "^2.1.2",
    "mocha": "^3.4.2",
    "mocha-bamboo-reporter": "*",
    "sinon": "^2.3.8",
    "supertest": "^3.0.0"
  },
  "scripts": {
    "test": "mocha",
    "forever-start": "forever start server.js -l -o -e",
    "bamboo": "node node_modules/mocha/bin/mocha -R mocha-bamboo-reporter"
  }
}

当我在我的计算机上本地运行测试时,我只需转到我的应用程序目录,打开控制台,编写 mocha --recursive --reporter min 并执行。然后,我所有的测试都运行得很完美,但是我必须先在我的计算机上全局安装 mocha。

如何在 Bamboo 中执行此操作?我尝试重新排列我的测试,以便它们不按文件夹组织,Bamboo 能够识别并运行它们,但我更喜欢将它们保存在单独的文件夹中。

顺便说一句,我遵循了 Atlassian 的教程 (https://confluence.atlassian.com/bamboocloud/getting-started-with-node-js-and-bamboo-737183843.html)

【问题讨论】:

    标签: mocha.js bamboo


    【解决方案1】:

    我还没有在竹子上做过摩卡咖啡测试,所以对这个建议持保留态度。这可能只是用竹子包装的罐装摩卡测试跑步者的限制。如果您不使用 mocha 测试运行程序竹子任务,而是尝试使用 vanilla 脚本任务代替它,然后在该脚本中执行您在本地机器上运行的相同命令,该怎么办。

    如果可行,并生成一个测试结果文件,那么您可以在该 shell 任务之后添加一个 mocha 测试结果解析器任务。

    此外,如果您要在很多项目中使用 mocha,您可以将它全局安装在竹服务器上 - 可能会减少一些执行时间。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-26
      • 2016-12-24
      • 2023-04-05
      • 2016-06-28
      相关资源
      最近更新 更多