Search code examples
restnode.jsbddmocha.jsvows

BDD Testing framework for Express.js


Here is what i need:

  1. Must be able to run test in Jenkins
  2. I want to test API, so I don't really care about functions and objects, I just want to make sure that when I send POST to /api/users.json, I will see that user in json array from GET /api/users/.

Is there any way I can run app and test in same process?

UPD.

Problem is half-solved: I have use mocha + should + restler to test my app. It is working. But How to set up jenkins to run these tests?


Solution

  • Freestyle Job -> execute shell script ->

    npm install
    node run.js &
    node_pid=$!
    sleep 15 // so tests won't fail because server not yet started
    ./node_modules/.bin/mocha --reporter tap > results/s-api.tap
    result=$? 
    kill $node_pid
    sleep 1 // so jenkins won't "scream" about leaked process
    return result // we need return code of tests