_ _ ___ ___
| | | | . |
|___|_|_|___|
- One file
uno.js
- One function
uno
- No dependencies
- Results are printed to console.log
uno(Math.round, [1.5], 2)
Output:
logs: "Uno test passed: round(1.5) == 2"
returns: true
Usage:
uno(name, fn, args, expected)
name
(optional) The name of the test. Excepts {inputs}, see below.fn
The function to testargs
A list of arguments passed tofn
expected
Whatfn(args)
should return
var date = new Date("October 31, 2012");
uno(date, date.getFullYear, [], 2012)
Output:
logs: "Uno test passed: object.getFullYear() == 2012"
returns: true
Usage:
uno(name, object, method, args, expected)
name
(optional) The name of the test. Excepts {inputs}, see below.object
The object to testmethod
The method to test (in the context ofobject
)args
A list of arguments passed tomethod
expected
Whatobject.method(args)
should return
All name
options support {input} strings. Here is a full list:
{method} // alias: {function} {fn} {f}
{args} // alias: {arguments} {input} {in}
{result} // alias: {output} {out}
{expected}
uno('Math.{fn}({args}), result: {result}, expected: {expected}', Math.round, [1.5], 2)
Output:
logs: "Uno test passed: Math.round(1.5), result: 2, expected: 2]"
returns: true
var date = new Date("October 31, 2012");
uno('date.{method}({args}) == {expected}', date, date.getFullYear, [], 2012)
Output:
logs: "Uno test passed: date.getFullYear() == 2012"
returns: true
(Almost done coding this)
(Still coding this one)
- Uno hooks into other unit testing frameworks and does the right thing to make them work too.
- Uno auto names tests using the function name and arguments
- qunit (close to finished)
- fireunit (close to finished)
- junit (just starting support)
npm install uno
uno = require('uno')
uno(Math.round, [1.5], 2) // logs: "Uno test passed: round(1.5) == 2"