iviTest
Simple REST API unit test, based from vowsjs and request.
Use chaijs to find BDD & TDD documentation.
Simple to use
just place your code in test folder inside ivitest main folder, or you can create custom folder anywhere.
request : {} // GLOBAL response : {} // GLOBAL "a context" : // LOCAL request : {} response : {} {} {} {}
Request
url : "http://google.com" method : "GET" // POST, GET, PUT, & etc headers : 'Content-Type': 'text/plain'
Response
Check data type
// sample response // { // data : [], // list : [], // body : {}, // foo : {}, // "check the child" : { // name : "", // address : "", // years : 2014, // age : 26, // } // } array : "data""list" object : "body""foo" "check the child" : string : "name""address" number : "years""age"
Check object inside array
// sample response // [ // { // "name" : "yuda", // "adress" : "surabaya", // } // ] each : "name""address" // each response has property name and address
callback
assert, should or expect can directly call from this function
// sample response // { // data : [], // list : [], // foo : {}, // "check the child" : { // name : "", // address : "", // years : 2014, // age : 26, // } // } { bodyshouldhavebe; tohavetobe; }
if you want to use first response as second request
var google = "request1" : request : method : "GET" url : "http://google.com" response : statusCode : 200 { return body : status : resstatusCode } "request2" : request : method : "POST" url : "http://custom.com/getstatus" body : detail : "status from google" response : statusCode : 200 moduleexports = google;
Before & After
var mongoose = ; mongoose; var user = mongoose
then execute them : ivitest
if you want to run test in other folder : ivitest -t /foldername
if you want to know all file to run : ivitest -l
if you want to execute just one file ( not all in one hit ) : ivitest -c 1
( number 1
can change with other number or string file name )
to see help : ivitest -h