aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/reporters/verbose.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ava/lib/reporters/verbose.js')
-rw-r--r--node_modules/ava/lib/reporters/verbose.js76
1 files changed, 55 insertions, 21 deletions
diff --git a/node_modules/ava/lib/reporters/verbose.js b/node_modules/ava/lib/reporters/verbose.js
index cd47683e8..c58d8db3b 100644
--- a/node_modules/ava/lib/reporters/verbose.js
+++ b/node_modules/ava/lib/reporters/verbose.js
@@ -5,7 +5,6 @@ const figures = require('figures');
const chalk = require('chalk');
const plur = require('plur');
const trimOffNewlines = require('trim-off-newlines');
-const extractStack = require('../extract-stack');
const codeExcerpt = require('../code-excerpt');
const colors = require('../colors');
const formatSerializedError = require('./format-serialized-error');
@@ -20,34 +19,46 @@ class VerboseReporter {
colors[key].enabled = this.options.color;
}
}
+
start() {
return '';
}
+
test(test, runStatus) {
+ const lines = [];
if (test.error) {
- return ' ' + colors.error(figures.cross) + ' ' + test.title + ' ' + colors.error(test.error.message);
- }
-
- if (test.todo) {
- return ' ' + colors.todo('- ' + test.title);
+ lines.push(' ' + colors.error(figures.cross) + ' ' + test.title + ' ' + colors.error(test.error.message));
+ } else if (test.todo) {
+ lines.push(' ' + colors.todo('- ' + test.title));
} else if (test.skip) {
- return ' ' + colors.skip('- ' + test.title);
- }
+ lines.push(' ' + colors.skip('- ' + test.title));
+ } else if (test.failing) {
+ lines.push(' ' + colors.error(figures.tick) + ' ' + colors.error(test.title));
+ } else if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') {
+ // No output
+ } else {
+ // Display duration only over a threshold
+ const threshold = 100;
+ const duration = test.duration > threshold ? colors.duration(' (' + prettyMs(test.duration) + ')') : '';
- if (test.failing) {
- return ' ' + colors.error(figures.tick) + ' ' + colors.error(test.title);
+ lines.push(' ' + colors.pass(figures.tick) + ' ' + test.title + duration);
}
- if (runStatus.fileCount === 1 && runStatus.testCount === 1 && test.title === '[anonymous]') {
- return undefined;
- }
+ if (test.logs) {
+ test.logs.forEach(log => {
+ const logLines = indentString(colors.log(log), 6);
+ const logLinesWithLeadingFigure = logLines.replace(
+ /^ {6}/,
+ ` ${colors.information(figures.info)} `
+ );
- // Display duration only over a threshold
- const threshold = 100;
- const duration = test.duration > threshold ? colors.duration(' (' + prettyMs(test.duration) + ')') : '';
+ lines.push(logLinesWithLeadingFigure);
+ });
+ }
- return ' ' + colors.pass(figures.tick) + ' ' + test.title + duration;
+ return lines.length > 0 ? lines.join('\n') : undefined;
}
+
unhandledError(err) {
if (err.type === 'exception' && err.name === 'AvaError') {
return colors.error(' ' + figures.cross + ' ' + err.message);
@@ -61,6 +72,7 @@ class VerboseReporter {
let output = colors.error(types[err.type] + ':', err.file) + '\n';
if (err.stack) {
+ output += ' ' + colors.stack(err.title || err.summary) + '\n';
output += ' ' + colors.stack(err.stack) + '\n';
} else {
output += ' ' + colors.stack(JSON.stringify(err)) + '\n';
@@ -70,6 +82,7 @@ class VerboseReporter {
return output;
}
+
finish(runStatus) {
let output = '';
@@ -86,7 +99,9 @@ class VerboseReporter {
].filter(Boolean);
if (lines.length > 0) {
- lines[0] += ' ' + chalk.gray.dim('[' + new Date().toLocaleTimeString('en-US', {hour12: false}) + ']');
+ if (this.options.watching) {
+ lines[0] += ' ' + chalk.gray.dim('[' + new Date().toLocaleTimeString('en-US', {hour12: false}) + ']');
+ }
output += lines.join('\n') + '\n';
}
@@ -104,6 +119,21 @@ class VerboseReporter {
}
output += ' ' + colors.title(test.title) + '\n';
+
+ if (test.logs) {
+ test.logs.forEach(log => {
+ const logLines = indentString(colors.log(log), 6);
+ const logLinesWithLeadingFigure = logLines.replace(
+ /^ {6}/,
+ ` ${colors.information(figures.info)} `
+ );
+
+ output += logLinesWithLeadingFigure + '\n';
+ });
+
+ output += '\n';
+ }
+
if (test.error.source) {
output += ' ' + colors.errorSource(test.error.source.file + ':' + test.error.source.line) + '\n';
@@ -132,9 +162,9 @@ class VerboseReporter {
}
if (test.error.stack) {
- const extracted = extractStack(test.error.stack);
- if (extracted.includes('\n')) {
- output += '\n' + indentString(colors.errorStack(extracted), 2) + '\n';
+ const stack = test.error.stack;
+ if (stack.includes('\n')) {
+ output += '\n' + indentString(colors.errorStack(stack), 2) + '\n';
}
}
@@ -153,15 +183,19 @@ class VerboseReporter {
return '\n' + trimOffNewlines(output) + '\n';
}
+
section() {
return chalk.gray.dim('\u2500'.repeat(process.stdout.columns || 80));
}
+
write(str) {
console.error(str);
}
+
stdout(data) {
process.stderr.write(data);
}
+
stderr(data) {
process.stderr.write(data);
}