aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/reporters/tap.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ava/lib/reporters/tap.js')
-rw-r--r--node_modules/ava/lib/reporters/tap.js47
1 files changed, 30 insertions, 17 deletions
diff --git a/node_modules/ava/lib/reporters/tap.js b/node_modules/ava/lib/reporters/tap.js
index 37c2cfd95..5ef8a23e3 100644
--- a/node_modules/ava/lib/reporters/tap.js
+++ b/node_modules/ava/lib/reporters/tap.js
@@ -3,12 +3,6 @@ const format = require('util').format;
const indentString = require('indent-string');
const stripAnsi = require('strip-ansi');
const yaml = require('js-yaml');
-const extractStack = require('../extract-stack');
-
-// Parses stack trace and extracts original function name, file name and line
-function getSourceFromStack(stack) {
- return extractStack(stack).split('\n')[0];
-}
function dumpError(error, includeMessage) {
const obj = Object.assign({}, error.object);
@@ -35,7 +29,7 @@ function dumpError(error, includeMessage) {
}
if (error.stack) {
- obj.at = getSourceFromStack(error.stack);
+ obj.at = error.stack.split('\n')[0];
}
return ` ---\n${indentString(yaml.safeDump(obj).trim(), 4)}\n ...`;
@@ -45,11 +39,13 @@ class TapReporter {
constructor() {
this.i = 0;
}
+
start() {
return 'TAP version 13';
}
+
test(test) {
- let output;
+ const output = [];
let directive = '';
const passed = test.todo ? 'not ok' : 'ok';
@@ -62,21 +58,34 @@ class TapReporter {
const title = stripAnsi(test.title);
+ const appendLogs = () => {
+ if (test.logs) {
+ test.logs.forEach(log => {
+ const logLines = indentString(log, 4);
+ const logLinesWithLeadingFigure = logLines.replace(
+ /^ {4}/,
+ ' * '
+ );
+
+ output.push(logLinesWithLeadingFigure);
+ });
+ }
+ };
+
+ output.push(`# ${title}`);
+
if (test.error) {
- output = [
- '# ' + title,
- format('not ok %d - %s', ++this.i, title),
- dumpError(test.error, true)
- ];
+ output.push(format('not ok %d - %s', ++this.i, title));
+ appendLogs();
+ output.push(dumpError(test.error, true));
} else {
- output = [
- `# ${title}`,
- format('%s %d - %s %s', passed, ++this.i, title, directive).trim()
- ];
+ output.push(format('%s %d - %s %s', passed, ++this.i, title, directive).trim());
+ appendLogs();
}
return output.join('\n');
}
+
unhandledError(err) {
const output = [
`# ${err.message}`,
@@ -89,6 +98,7 @@ class TapReporter {
return output.join('\n');
}
+
finish(runStatus) {
const output = [
'',
@@ -105,12 +115,15 @@ class TapReporter {
return output.join('\n');
}
+
write(str) {
console.log(str);
}
+
stdout(data) {
process.stderr.write(data);
}
+
stderr(data) {
this.stdout(data);
}