Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to I configure TeamCity build with Mocha?

How to I configure TeamCity build with Mocha?

Problem

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?

Problem courtesy of: willz

Solution

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

Solution courtesy of: Val

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

How to I configure TeamCity build with Mocha?

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×