1
votes

Executing karma test cases in a maven build produces the following error:

[INFO] Executing Karma Test Suite ...
cmd /C karma start C:\.....\karma.conf.js --browsers Chrome --single-run --no-auto-watch --colors true
'karma' is not recognized as an internal or external command, 
operable program or batch file.

While in the jenkins server when karma is run manually its working and test report is generated. How to get it done in jenkins build? Should i configure nodeJS or karma path anywhere in jenkins? Please help if anyone knows.

1
The second paragraph is not clear, do you mean the test passed when you locally ran it on the server? - RejeeshChandran
Yes when i run it in the command promt of server machine: karma start is working. Which means node-modules for karma is installed in the system right? But on jenkins build it fails - Ria Pius
I reffered the link: myshittycode.com/2014/11/11/… to do the settings. - Ria Pius
can you refer stackoverflow.com/questions/20800933/…. Not sure it will help or not. - RejeeshChandran
As mentioned in the link above, tried npm install -g karma-cli , all the node modules are present in the server. Still getting the same error while building via jenkins - Ria Pius

1 Answers

0
votes

Ok, I finally could figure out what the problem was..

  1. Install karma-cli globally

    npm install -g karma-cli

  2. Open control panel->system>Edit System Environment Variables->Search for the variable Path in the global section and click Edit. In the value field, go to the end, and if it doesnt end with a semicolon, add a semicolon ";", then this: %AppData%\npm; Leave no spaces between words/values or after any semicolon.

  3. Restart Jenkins Service (I rather doing it from the Services Applet within the Admin Tools Menu), just find Jenkins and click "Restart" in the column at the right.

Now your windows batch command "karma start karma.conf" should work flaulessly !

It did for me... :)