如何使用 Mocha 配置 TeamCity 构建? [英] How to I configure TeamCity build with Mocha?

查看:21
本文介绍了如何使用 Mocha 配置 TeamCity 构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目,我正在通过 teamcity 为 CI 设置.该项目本身是一个 nodejs 应用程序,它包括用 mocha 编写的测试,我们通过 jscoverage 进行介绍.在我正在设置的构建配置中,我有 3 个构建步骤在签到时发生.

I have a project that I am setting up through teamcity for CI. The project itself is a nodejs application and it includes test written in mocha, which we cover through jscoverage. In the build configuration I'm setting up I have 3 build steps which occur on checkin.

  1. 针对我所在项目中的文件夹调用 jscoverage.exe覆盖.

  1. call jscoverage.exe against the folders in my project that I'm covering.

调用 mocha 以针对步骤 1 中的 jscovered 文件运行测试并输出到 html-cov 报告器

call mocha to run the test against the jscovered files from step 1 and output to the html-cov reporter

将生成的coverage.html 报告移至公共网络目录稍后浏览.

move the generated coverage.html report into a public web directory to browse later.

构建当前在第 2 步失败:mocha" 不存在于目录 C:NodeJSMeasuresAPI

The build currently fails on step 2: mocha" is not present in directory C:NodeJSMeasuresAPI

我已确保在系统环境路径中包含 mocha 和我的所有节点包,并且我能够在命令提示符下访问它们,但 TeamCity 似乎看不到它们.

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.

对于 jscoverage.exe,我必须包含完整路径.使用 mocha,我尝试包含安装 mocha 的节点全局安装的路径,但它给了我一个错误:

for the jscoverage.exe, I had to include the full path. With mocha, I tried including the path to my node global installation where mocha installed to but it gives me an error:

.. ode_modulesmochainmocha"(在目录C:NodeJSMeasuresAPI"中):CreateProcess 错误=193,%1 不是有效的 Win32 应用程序

".. ode_modulesmochainmocha" (in directory "C:NodeJSMeasuresAPI"): CreateProcess error=193, %1 is not a valid Win32 application

有人对 Teamcity 和 Mocha 有任何经验,以及如何让它们玩得更好?或与 nodejs、mocha 堆栈持续集成的任何想法?

Anyone had any experience with Teamcity and Mocha and how to get them to play nice? or any ideas for continuous integration with a nodejs, mocha stack?

推荐答案

是的,这也发生在我身上,当时我正在设置 TeamCity 以在 Windows Server 上运行 mocha.解决方案是通过指定 mocha.cmd bat 文件的路径来调用 mocha.例如,如果您有文件夹 C:mocha 并且您已执行npm install mocha

Yes , this happened to me too, when I was setting up TeamCity to run mocha on Windows Server. The solution was to call mocha by specifying path to the mocha.cmd bat file. For example , if you have folder C:mocha and you have executed npm install mocha

在那个目录中,bat文件的路径将是

in that directory , than path to the bat file will be

C:mocha ode_modules.binmocha.cmd

C:mocha ode_modules.binmocha.cmd

您可以通过下一条指令告诉 Teamcity 执行 mocha 命令:

And you can tell Teamcity to execute mocha command by giving it next instruction :

C:mocha ode_modules.binmocha --ui tdd --reporter html-cov testmeasureDBTests.js > coverage.html

C:mocha ode_modules.binmocha --ui tdd --reporter html-cov testmeasureDBTests.js > coverage.html

这篇关于如何使用 Mocha 配置 TeamCity 构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆