aboutsummaryrefslogtreecommitdiff
path: root/node_modules/ava/lib/reporters/mini.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/ava/lib/reporters/mini.js')
-rw-r--r--node_modules/ava/lib/reporters/mini.js53
1 files changed, 42 insertions, 11 deletions
diff --git a/node_modules/ava/lib/reporters/mini.js b/node_modules/ava/lib/reporters/mini.js
index 8acfab8e7..a21d02a6b 100644
--- a/node_modules/ava/lib/reporters/mini.js
+++ b/node_modules/ava/lib/reporters/mini.js
@@ -5,12 +5,12 @@ const lastLineTracker = require('last-line-stream/tracker');
const plur = require('plur');
const spinners = require('cli-spinners');
const chalk = require('chalk');
+const figures = require('figures');
const cliTruncate = require('cli-truncate');
const cross = require('figures').cross;
const indentString = require('indent-string');
const ansiEscapes = require('ansi-escapes');
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');
@@ -33,6 +33,7 @@ class MiniReporter {
this.stream = process.stderr;
this.stringDecoder = new StringDecoder();
}
+
start() {
this.interval = setInterval(() => {
this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;
@@ -41,6 +42,7 @@ class MiniReporter {
return this.prefix('');
}
+
reset() {
this.clearInterval();
this.passCount = 0;
@@ -56,13 +58,16 @@ class MiniReporter {
this.spinnerIndex = 0;
this.lastLineTracker = lastLineTracker();
}
+
spinnerChar() {
return this.spinnerFrames[this.spinnerIndex];
}
+
clearInterval() {
clearInterval(this.interval);
this.interval = null;
}
+
test(test) {
if (test.todo) {
this.todoCount++;
@@ -83,6 +88,7 @@ class MiniReporter {
return this.prefix(this._test(test));
}
+
prefix(str) {
str = str || this.currentTest;
this.currentTest = str;
@@ -91,6 +97,7 @@ class MiniReporter {
// TODO(jamestalmage): Figure out why it's needed and document it here
return ` \n ${this.spinnerChar()} ${str}`;
}
+
_test(test) {
const SPINNER_WIDTH = 3;
const PADDING = 1;
@@ -102,6 +109,7 @@ class MiniReporter {
return title + '\n' + this.reportCounts();
}
+
unhandledError(err) {
if (err.type === 'exception') {
this.exceptionCount++;
@@ -109,6 +117,7 @@ class MiniReporter {
this.rejectionCount++;
}
}
+
reportCounts(time) {
const lines = [
this.passCount > 0 ? '\n ' + colors.pass(this.passCount, 'passed') : '',
@@ -124,6 +133,7 @@ class MiniReporter {
return lines.join('');
}
+
finish(runStatus) {
this.clearInterval();
let time;
@@ -163,6 +173,21 @@ class MiniReporter {
}
status += ' ' + 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)} `
+ );
+
+ status += logLinesWithLeadingFigure + '\n';
+ });
+
+ status += '\n';
+ }
+
if (test.error.source) {
status += ' ' + colors.errorSource(test.error.source.file + ':' + test.error.source.line) + '\n';
@@ -191,9 +216,9 @@ class MiniReporter {
}
if (test.error.stack) {
- const extracted = extractStack(test.error.stack);
- if (extracted.includes('\n')) {
- status += '\n' + indentString(colors.errorStack(extracted), 2) + '\n';
+ const stack = test.error.stack;
+ if (stack.includes('\n')) {
+ status += '\n' + indentString(colors.errorStack(stack), 2) + '\n';
}
}
@@ -212,14 +237,14 @@ class MiniReporter {
status += ' ' + colors.error(cross + ' ' + err.message) + '\n\n';
} else {
const title = err.type === 'rejection' ? 'Unhandled Rejection' : 'Uncaught Exception';
- let description = err.stack ? err.stack.trimRight() : JSON.stringify(err);
- description = description.split('\n');
- const errorTitle = err.name ? description[0] : 'Threw non-error: ' + description[0];
- const errorStack = description.slice(1).join('\n');
-
status += ' ' + colors.title(title) + '\n';
- status += ' ' + colors.stack(errorTitle) + '\n';
- status += colors.errorStack(errorStack) + '\n\n';
+
+ if (err.name) {
+ status += ' ' + colors.stack(err.summary) + '\n';
+ status += colors.errorStack(err.stack) + '\n\n';
+ } else {
+ status += ' Threw non-error: ' + err.summary + '\n';
+ }
}
});
}
@@ -235,24 +260,30 @@ class MiniReporter {
return '\n' + trimOffNewlines(status) + '\n';
}
+
section() {
return '\n' + chalk.gray.dim('\u2500'.repeat(process.stdout.columns || 80));
}
+
clear() {
return '';
}
+
write(str) {
cliCursor.hide();
this.currentStatus = str;
this._update();
this.statusLineCount = this.currentStatus.split('\n').length;
}
+
stdout(data) {
this._update(data);
}
+
stderr(data) {
this._update(data);
}
+
_update(data) {
let str = '';
let ct = this.statusLineCount;