complete() callback to indicate test completion.
The above example illustrates the basic syntax of a single test, however loading your tests is done via the sink module which exports the test and ok methods. See the example below:
// start all test modules
// tests.jsvar sink =var start = sinkstartsink = sinksink
in your terminal
$ node path/to/my/tests.js
Sink Test follows most of the assert module specified in the CommonJS Unit-Testing/1.0 assert module and gives you additional convenience assertions plus an API to define your own assertions.
Basic assert calls perform a strict equals:
; // performs: actual === expected
assert method is extended, giving you aliases for the above:
assert;assert;// and the inverse:assert;assert;
And also an alias for the simple boolean
A non-strict deep equals is available via:
assert;assert;// and the inverse:assert;
And many additional assertions to make your tests clear and obvious:
assert; // performs a "typeof value == type"assert;assert;assert;assert;assert;assert;assert;assert;assert;assert;assert;assert;assert;assert; // is the value a DOM element
The message parameter on all assertions is optional.
When you have a complex condition to assert, you can define a custom assertion for it with the
Simply provide your assertion name and the handler function. Handler functions can take one or two arguments:
// single-argument form:assert;// use it:assert; // → failassert; // → pass// dual-argument form:assert;// use it:assert;