Can I use WebStorm+Karma+Jasmine to test NodeJS server code?

I'm trying to setup Jasmine unit testing for both a NodeJS back end server and a Sencha Touch front end client and hopefully support running these tests under IntelliJ IDEA 13.0.
I'm posting here because I figure that the solution should work for WebStorm and it's probably the most likely place other devs will look.

The confusion is that Karma (since it runs in the browser) was originally designed for testing front end code only.
So can someone explain how/if it's possible to get the back end unit tests running under Karma.
I'm particularly keen to make use of the code coverage features.

I've viewed all the videos and JetBrains docs on Karma but I must be missing something.

Thanks.

4 comments
Comment actions Permalink

The key stopping point is that my unit tests fail to recognise the NodeJS require() method so obviously the NodeJS environment is not setup. I suspect that I may need the jasmine-node package but I'm unsure how to itegrate this with the WebStorm/Karma tools.
   https://github.com/mhevery/jasmine-node

0
Comment actions Permalink

OK I found this feature request that's been waiting since WebStorm 4 !

  http://devnet.jetbrains.com/thread/436496

I also found this old post:
  http://devnet.jetbrains.com/thread/433923

So does the new Karma feature in WS 7 allow another solution for this or is it only client side unit testing?

0
Comment actions Permalink

OK looks like mocha is better supported.  Hope it can do code coverage as well.

0
Comment actions Permalink

Hello!

indeed karma was designed for testing browser-based code, so using it for testing node.js backend is a pain... See the related thread: http://stackoverflow.com/questions/16660670/how-to-test-nodejs-backend-code-with-karma-testacular

Mocha is more suitable for node testing. Unfortunately coverage is not yet supported :( Please vote for http://youtrack.jetbrains.com/issue/WEB-10373

0

Please sign in to leave a comment.