Tap
Render TAP-formatted output.
Methods
Static
StylesObject —Available styles. See Customization.
-
messageToString(val, indent)function —This function is used to get the string value of messages passed to
renderDiagnostic.
Properties
new Tap(style, debug, EOL)
Creates a new Tap object and sets the this.style, this.debug, and this.EOL properties.
-
styleObject —define style prefixes for output elements
(default:Tap.Styles.None) -
debugbool —include stack trace in error output if
(default:truefalse) -
EOLstring —line ending used when rendering output
(default:'\n')
Examples
const {Tap} = require('spooning');
const tap = new Tap(Tap.Styles.Unicode);
renderPlan(count)
Render and return a TAP plan string.
-
countnumber —the number of tests to be run
Examples
return tap.renderPlan(4); // returns "1..4"
renderResult(ok, idx, name, suffix)
Render and return a TAP result string.
-
okbool —trueif the test passed, otherwisefalse -
idxnumber —test number (determined by order finished)
-
namestring —test name
-
suffixstring —will be prefixed with
this.EOLand added to the end of the result string
Examples
return tap.renderResult(true, 1); // returns "ok 1"
renderDiagnostic(message, prefix)
Render and return a TAP diagnostic string.
-
messageany —message to display
-
prefixstring —prefix will be added to each line in rendered message
(default:'# ')
Examples
return tap.renderDiagnostic('Test message'); // returns "# Test message"
handleStart(info)
Render and return a TAP plan string.
-
infoRunStartInfo
Examples
return tap.handleStart({count: 4}); // returns "1..4"
handleEnd(info)
Render and return a TAP diagnostic message containing a footer with final result counts.
-
infoRunEndInfo
Examples
return tap.handleEnd({total: 4, passed: 4}); // returns "# test: 4\n# pass: 4\n# fail: 0"
handleResult(info)
Render and return a TAP result message that includes any error and/or diagnostic message provided.
-
infoTestResultInfo
Examples
return tap.handleResult({idx: 1, name: 'expected message'}); // returns "ok 1 - expected message"
prefixLines(text, prefix)
Add a prefix to every line of a string.
Examples
console.log(tap.prefixLines('Test message\nSecond line\nThird line', '# ! '))Output
# ! Test message
# ! Second line
# ! Third line
setStyle(style)
Set the this.style property. Changes the style used when rendering output.
-
styleTapStyle
setDebug(isEnabled)
Set the this.debug property. Causes Error stack to be included in output if true.
-
isEnabledbool
setEOL(eol)
Set the this.EOL property. Changes the line ending character used when rendering output.
-
eolstring
Tap.messageToString(val, indent)
This function is used to get the string value of messages passed to renderDiagnostic.
-
valany —value to be stringified (maybe)
-
indentnumber —number of spaces used to indent the JSON object
(default:2)
See
-
maybeStringify
—
used by this function to produce the string
-
this.renderDiagnostic
—
uses this function to get the string value of
message