Adds easy to use life-cycle functions for tape tests.
Add before
and after
options to either test
or t.test
.
A before
test will complete when the test passed to it completes (either through t.end
or when the plan
completes.
Example:
var test = require('taped');
test('taped', {
before: function (t) {
//Call t.end directly.
t.end();
},
after: function () {
//Cleanup
}
}, function (t) {
t.test('test', {
before: function (t) {
//Using plan.
t.plan(1);
t.pass('before called.');
},
after: function () {
//Cleanup
}
}, function (t) {
t.pass('everything ran.');
t.end();
});
});