yessir
Yessir soups up Node's assert module and plays nicely with nodeunit, providing helpers to reduce unit test boilerplate.
Getting Started
Install the module with: npm install yessir
var Yessir = ;Yessirtest = ; //defaults to assert, can easily be test for nodeunit
Methods
- testObj(obj, tests) - Run tests on
obj
.tests
is anObject
where each key represents a test to be run onobj
.tests
accepts various keys (of deep properties) and values, including:
'key': 'john' //if key is a property of obj, test are run on the value of the property, otherwise value is treated as the object as a whole 'name': true //if value is a boolean, existence or non-existence of the property of object is tested 'name': /john/ //if value is a RegExp, obj.key is tested to see if it matches value { return 'john' === value; } //if value is a function, is it called with arguments of value and key, bound to obj 'name': ... //if value is an array, each element is treated as a test 'name': anything //anything else is tested for deep equality with value
- testCb(cb, tests, [ind]) - Returns a function that when called applies
tests
toarguments
before invokingcb
with no only arguments[ind] or no arguments if ind is undefined
License
Copyright (c) 2014 Ben Sack Licensed under the MIT license.