Skip to content

Commit 14b77d8

Browse files
Juan Sotosindresorhus
Juan Soto
authored andcommitted
Close #639 PR: Truncate mini reporter titles. Fixes #629
1 parent 62acd21 commit 14b77d8

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

lib/reporters/mini.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var plur = require('plur');
66
var spinners = require('cli-spinners');
77
var chalk = require('chalk');
88
var colors = require('../colors');
9+
var cliTruncate = require('cli-truncate');
910

1011
chalk.enabled = true;
1112
Object.keys(colors).forEach(function (key) {
@@ -75,7 +76,7 @@ MiniReporter.prototype.prefix = function (str) {
7576
};
7677

7778
MiniReporter.prototype._test = function (test) {
78-
var title = test.title;
79+
var title = cliTruncate(test.title, process.stdout.columns - 3);
7980

8081
if (test.todo) {
8182
this.todoCount++;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"chalk": "^1.0.0",
9090
"cli-cursor": "^1.0.2",
9191
"cli-spinners": "^0.1.2",
92+
"cli-truncate": "^0.1.0",
9293
"co-with-promise": "^4.6.0",
9394
"common-path-prefix": "^1.0.0",
9495
"convert-source-map": "^1.1.2",

test/reporters/mini.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ chalk.enabled = true;
99

1010
var graySpinner = chalk.gray.dim('⠋');
1111

12+
// Needed because tap doesn't emulate a tty environment and thus this is
13+
// undefined, making `cli-truncate` append '...' to test titles
14+
process.stdout.columns = 5000;
15+
1216
function miniReporter() {
1317
var reporter = _miniReporter();
1418
reporter.start = function () {

0 commit comments

Comments
 (0)