1

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.

Bricktop
  • 1,549
  • 14
  • 23
Ria Pius
  • 26
  • 3
  • The second paragraph is not clear, do you mean the test passed when you locally ran it on the server? – RejeeshChandran Jan 20 '17 at 11:17
  • 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 Jan 20 '17 at 13:00
  • I reffered the link: https://myshittycode.com/2014/11/11/jenkins-getting-karma-generated-test-results-to-appear-in-maven-project-job/ to do the settings. – Ria Pius Jan 20 '17 at 13:02
  • can you refer http://stackoverflow.com/questions/20800933/running-karma-after-installation-results-in-karma-is-not-recognized-as-an-inte. Not sure it will help or not. – RejeeshChandran Jan 20 '17 at 13:09
  • 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 Feb 02 '17 at 05:53
  • Hi Ria, could you actually resolve this issue? I am having the same problem and it seems to be a hard one to figure out. If you did, could you please share your experience and what the solution was? Thanks! – Will de la Vega May 03 '17 at 02:53

1 Answers1

0

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... :)

Will de la Vega
  • 536
  • 1
  • 5
  • 17