简体   繁体   English

如何使用Mocha配置TeamCity构建?

[英]How to I configure TeamCity build with Mocha?

I have a project that I am setting up through teamcity for CI. 我有一个项目,我通过teamcity为CI设置。 The project itself is a nodejs application and it includes test written in mocha, which we cover through jscoverage. 项目本身是一个nodejs应用程序,它包括用mocha编写的测试,我们通过jscoverage覆盖。 In the build configuration I'm setting up I have 3 build steps which occur on checkin. 在我正在设置的构建配置中,我有3个构建步骤,这些步骤在签入时发生。

  1. call jscoverage.exe against the folders in my project that I'm covering. 调用jscoverage.exe对我正在覆盖的项目中的文件夹。

  2. call mocha to run the test against the jscovered files from step 1 and output to the html-cov reporter 调用mocha对步骤1中的jscovered文件运行测试并输出到html-cov报告器

  3. move the generated coverage.html report into a public web directory to browse later. 将生成的coverage.html报告移动到公共Web目录中以便稍后浏览。

The build currently fails on step 2: mocha" is not present in directory C:\\NodeJS\\MeasuresAPI 构建当前在步骤2中失败:目录C:\\ NodeJS \\ MeasuresAPI中不存在mocha“

I've made sure to include mocha and all my node packages in the system environment paths and I am able to access them in the command prompt, but TeamCity doesnt appear to see them. 我确保在系统环境路径中包含mocha和我的所有节点包,并且我能够在命令提示符中访问它们,但是TeamCity似乎没有看到它们。

for the jscoverage.exe, I had to include the full path. 对于jscoverage.exe,我必须包含完整路径。 With mocha, I tried including the path to my node global installation where mocha installed to but it gives me an error: 使用mocha,我尝试将路径添加到我的节点全局安装中,其中安装了mocha但是它给了我一个错误:

"..\\node_modules\\mocha\\bin\\mocha" (in directory "C:\\NodeJS\\MeasuresAPI"): CreateProcess error=193, %1 is not a valid Win32 application “.. \\ node_modules \\ mocha \\ bin \\ mocha”(在目录“C:\\ NodeJS \\ MeasuresAPI”中):CreateProcess error = 193,%1不是有效的Win32应用程序

Anyone had any experience with Teamcity and Mocha and how to get them to play nice? 任何人都有Teamcity和Mocha的经验以及如何让他们玩得很好? or any ideas for continuous integration with a nodejs, mocha stack? 或任何与nodejs,mocha堆栈持续集成的想法?

Yes , this happened to me too, when I was setting up TeamCity to run mocha on Windows Server. 是的,当我设置TeamCity在Windows Server上运行mocha时,这也发生在我身上。 The solution was to call mocha by specifying path to the mocha.cmd bat file. 解决方案是通过指定mocha.cmd bat文件的路径来调用mocha。 For example , if you have folder C:\\mocha and you have executed npm install mocha 例如,如果你有文件夹C:\\ mocha,你已经执行了npm install mocha

in that directory , than path to the bat file will be 在该目录中,将比bat文件的路径

C:\\mocha\\node_modules.bin\\mocha.cmd C:\\摩卡\\ node_modules.bin \\ mocha.cmd

And you can tell Teamcity to execute mocha command by giving it next instruction : 你可以通过给它下一条指令告诉Teamcity执行mocha命令:

C:\\mocha\\node_modules.bin\\mocha --ui tdd --reporter html-cov test\\measureDBTests.js > coverage.html C:\\ mocha \\ node_modules.bin \\ mocha --ui tdd --reporter html-cov test \\ measureDBTests.js> coverage.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM