How to I configure TeamCity build with Mocha?

北城余情 提交于 2020-01-01 02:51:09

问题


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. call jscoverage.exe against the folders in my project that I'm covering.

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

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

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

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.

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:

"..\node_modules\mocha\bin\mocha" (in directory "C:\NodeJS\MeasuresAPI"): CreateProcess error=193, %1 is not a valid Win32 application

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?


回答1:


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

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

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

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

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



来源:https://stackoverflow.com/questions/9935549/how-to-i-configure-teamcity-build-with-mocha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!