Virile testing for http servers or any nodejs application
Virile testing for http servers or any nodejs application.
npm install testosterone
Testosterone allows you to follow BDD or TDD on any of your projects using the same testing library.
host: Host to do the http calls. localhost
port: Port to do the http calls. 80
output: Configure the amount of verbosity you want for your tests
specs: Print the specs true
ticks: Print the ✓ and ✗ ticks true
summary: Prints the summary true
title: Prints the title true
title: Test title, it will be printed out. Testosterone
sync: If set to
true, you don't need to call
doneto specify when your tests are done. false
testosterone API is simple and flexible.
get|post|head|put|delete...(url, req, response, cb): Does a http call with the given request. If a response is given, testosterone will assert that the real response matches.
add(spec, function(done)): Adds a test. The test is considered executed when
donefunction is called.
before(function): Runs before each test.
after(function): Runs after each test.
run([cb]): Runs the tests in serial.
cbwill be called once all the tests are executed.
assert: You must use this assert object instead of the native one.
All the functions are chainable.
You have more examples on the
var testosterone = port: 3000assert = testosteroneassert;testosterone;// Output$ node testjs✿ Testosterone : ✓ ✓ ✓ ✓ ✓» 3 responses 5 asserts
var testosterone = post: 3000 title: 'Testing async'assert = testosteroneassert;testosterone// using done to tell testosterone when the test is done// same but currying;// Output$ node testjs✿ Testing async :First ✓Second ✓ ✓» 0 responses 3 asserts
var testosterone = post: 3000 title: 'Testing with stubs' sync: truegently = newfs =assert = testosteroneassert;testosterone;// Output$ node testjs✿ Testing with stubs :GIVEN footxtWHEN its emptyTHEN it return ✓ ✓ ✓GIVEN footxtWHEN it have contentTHEN it return that ✓ ✓ ✓» 6 asserts
In order to run the tests type:
npm installmake test_appmake