Skip to content

Commit 21bdcc5

Browse files
Juansindresorhus
Juan
authored andcommitted
Add test-like output when test file does not exist
1 parent 61848ee commit 21bdcc5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/reporters/mini.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var spinners = require('cli-spinners');
77
var chalk = require('chalk');
88
var cliTruncate = require('cli-truncate');
99
var colors = require('../colors');
10+
var cross = require('figures').cross;
1011

1112
chalk.enabled = true;
1213
Object.keys(colors).forEach(function (key) {
@@ -131,7 +132,7 @@ MiniReporter.prototype.reportCounts = function () {
131132
status += '\n ' + colors.todo(this.todoCount, 'todo');
132133
}
133134

134-
return status.length ? status : '\n';
135+
return status;
135136
};
136137

137138
MiniReporter.prototype.finish = function () {
@@ -180,7 +181,7 @@ MiniReporter.prototype.finish = function () {
180181
i++;
181182

182183
if (err.type === 'exception' && err.name === 'AvaError') {
183-
status += '\n\n ' + colors.error(i + '. ' + err.message) + '\n';
184+
status += '\n\n ' + colors.error(cross + ' ' + err.message) + '\n';
184185
} else {
185186
var title = err.type === 'rejection' ? 'Unhandled Rejection' : 'Uncaught Exception';
186187
var description = err.stack ? err.stack : JSON.stringify(err);
@@ -200,7 +201,7 @@ MiniReporter.prototype.finish = function () {
200201

201202
MiniReporter.prototype.write = function (str) {
202203
cliCursor.hide();
203-
this.currentStatus = str + '\n';
204+
this.currentStatus = str;
204205
this._update();
205206
this.statusLineCount = this.currentStatus.split('\n').length;
206207
};

test/reporters/mini.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var test = require('tap').test;
44
var AvaError = require('../../lib/ava-error');
55
var _miniReporter = require('../../lib/reporters/mini');
66
var beautifyStack = require('../../lib/beautify-stack');
7+
var cross = require('figures').cross;
78

89
chalk.enabled = true;
910

@@ -255,7 +256,7 @@ test('results with passing tests and exceptions', function (t) {
255256
t.match(output[5], /Error: failure/);
256257
t.match(output[6], /test\/reporters\/mini\.js/);
257258
var next = 6 + output.slice(6).indexOf('') + 1;
258-
t.is(output[next], ' ' + chalk.red('2. A futuristic test runner'));
259+
t.is(output[next], ' ' + chalk.red(cross + ' A futuristic test runner'));
259260
t.end();
260261
});
261262

@@ -291,6 +292,6 @@ test('empty results after reset', function (t) {
291292
reporter.reset();
292293

293294
var output = reporter.finish();
294-
t.is(output, '\n\n');
295+
t.is(output, '\n');
295296
t.end();
296297
});

0 commit comments

Comments
 (0)