Ph0en1x
Ph0en1x

Reputation: 10067

Jasmine + Node.js for server side unittesting. How to run tests?

I need to be able to run unit test for my Node.js application, I decide to use Jasmine framework, because I know t and think it's pretty well solution. But before I use karma as my test runner, but karma do not works for server side development. So, please, advice me a good way to develop unit test for Node.js with Jasmine

Upvotes: 1

Views: 4493

Answers (2)

artkoshelev
artkoshelev

Reputation: 892

According to Jasmine documentation you can use 'jasmine' node package. Running jasmine init will create basic jasmin.json configuration file, where you can list all your specs.

Upvotes: 2

Ostro
Ostro

Reputation: 338

im currently using this project to run mt jasmine's test https://github.com/mhevery/jasmine-node

you simply need to exec this : jasmine-node path/to/your/specs

May be this is not the best tools for running jasmine specs but i use it because it supports coffescript written specs (jasmine-node --coffee specs/

and finally you could use it to make starting "script" like run test before any action

jasmine-node specs/specs1.js && jasmine-node specs/specs2.js && node server.js for example

an other cool tool i use is rewire https://github.com/jhnns/rewire that allow you to mock some methods fir unit testing

i hope it might help you

Upvotes: 2

Related Questions