Reporter
This class establishes the Reporter protocol: an object that implements runStart, runEnd and testResult.
An object with this signature may be passed as the first argument to the TestQueue
constructor. See Customization for more information.
The default implementation writes TAP-formatted output to the provided stream.
All callback functions are passed to the this.stream.write function.
If an error is thrown or emitted during a write operation, it is caught and passed to the callback.
Methods
new Reporter(tap, stream)
Creates a new Reporter object and sets the this.tap and this.stream properties.
Examples
const {Tap, Reporter} = require('spooning');
const reporter = new Reporter(new Tap(), process.stdout);
runStart(info, callback)
Write a TAP plan to this.stream.
-
infoRunStartInfo -
callbackfunction —called when write finishes
-
errorError —write error (or falsy value if none occurred)
-
See
Examples
reporter.runStart({count: 2}, () => {
// plan has been written
});
runEnd(info, callback)
Write a footer with final result counts as a TAP diagnostic message to this.stream.
-
infoRunEndInfo -
callbackfunction —called when write finishes
-
errorError —write error (or falsy value if none occurred)
-
See
Examples
reporter.runEnd({total: 2, passed: 1}, () => {
// footer has been written
});
testResult(info, callback)
Write a TAP result to this.stream.
-
infoTestResultInfo -
callbackfunction —called when write finishes
-
errorError —write error (or falsy value if none occurred)
-
See
Examples
reporter.testResult({idx: 1, name: 'Should pass'}, () => {
// result has been written
});