✿ Testosterone
Virile testing for http servers or any nodejs application.
Installation
npm install testosterone
WhateverDrivenDevelopment
Testosterone allows you to follow BDD or TDD on any of your projects using the same testing library.
Options
host
: Host to do the http calls. localhostport
: Port to do the http calls. 80output
: Configure the amount of verbosity you want for your testsspecs
: Print the specs trueticks
: Print the ✓ and ✗ ticks truesummary
: Prints the summary truetitle
: Prints the title true
title
: Test title, it will be printed out. Testosteronesync
: If set totrue
, you don't need to calldone
to specify when your tests are done. false
API
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 whendone
function is called.before(function)
: Runs before each test.after(function)
: Runs after each test.run([cb])
: Runs the tests in serial.cb
will 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.
Show me the code
You have more examples on the test
folder:
HTTP testing example:
var testosterone = port: 3000assert = testosteroneassert;testosterone;// Output$ node testjs✿ Testosterone : ✓ ✓ ✓ ✓ ✓» 3 responses 5 asserts
Asynchronous example:
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
gently stubbing and sync: true
:
Example with 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
Test
In order to run the tests type:
npm installmake test_appmake
Credits
The _call function of this library is a shameless copy from expresso response assert done by TJ Holowaychuk (visionmedia)