When calling runner.run(), you can provide a callback function that receives a run object. By calling run.start(), you can pass an object containing various lifecycle hooks (callbacks). These hooks allow you to intercept and react to different stages of the collection execution, such as when a request starts, when an assertion is made, or when an error occurs.
Common use cases include logging progress, capturing test results, monitoring network IO, or handling exceptions during the run.
runner.run(collection, { /* options */ }, function(err, run) {
run.start({
start: function (err, cursor) { /* ... */ },
assertion: function (cursor, assertions) { /* ... */ },
done: function (err) { /* ... */ },
// ... other lifecycle hooks
});
});