I created a simple Webapp using express.js and want to test it with jasmine-node. Works fine so far but my problem is that I have to start the server manually every time before I can run my tests.
Could you help me on how to write a spec-helper that runs the server (with another port then my development one) just for the tests and then kills it afterwards?
This is what I do:
I have a server.js file inside the root of my node project that sets up the node application server (with express) and exports 2 methods:
The app.js file will be simple at this point:
So the files/folder basic structure would be the following:
Having this separation will allow you to run the server normally:
..and/or require it from a custom node script, which could be a node script (or a jake/grunt/whatever task) that executes your tests like this: