在Bamboo上运行Mocha测试

时间:2017-08-03 16:04:14

标签: mocha bamboo

我试图在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

1 个答案:

答案 0 :(得分:0)

我还没有对竹子做过摩卡测试,所以采取这种建议大量的盐。这可能仅仅是用竹子包装的罐装摩卡测试跑步机的限制。如果不使用mocha测试运行器竹子任务,你在其位置尝试了一个vanilla脚本任务,只需执行在该脚本中在本地盒子上运行的相同命令。

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

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

相关问题