Skip to content

Commit d037e0f

Browse files
committed
Flexible column width based on spec path length
1 parent 34d9873 commit d037e0f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/cli.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const path = require('path');
66
const fs = require('fs-extra');
77
const { settings } = require('./settings');
88

9-
const { getTestSuitePaths, distributeTestsByWeight } = require('./test-suites');
9+
const { getTestSuitePaths, distributeTestsByWeight, getMaxPathLenghtFrom } = require('./test-suites');
1010
const {
1111
formatTime,
1212
generateWeightsFile,
@@ -55,7 +55,7 @@ async function start() {
5555
let table = new Table({
5656
head: ['Spec', 'Time', 'Tests', 'Passing', 'Failing', 'Pending'],
5757
style: { head: ['blue'] },
58-
colWidths: [50, 8, 7, 9, 9, 9]
58+
colWidths: [getMaxPathLenghtFrom(testSuitePaths), 10, 10, 10, 10, 10]
5959
});
6060

6161
let totalTests = 0;

lib/test-suites.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ async function getTestSuitePaths() {
5858
return fileList;
5959
}
6060

61+
function getMaxPathLenghtFrom(testSuitePaths) {
62+
let maxLength = 10;
63+
64+
for(let path of testSuitePaths){
65+
maxLength = Math.max(maxLength, path.length);
66+
}
67+
68+
return maxLength + 3;
69+
}
70+
6171
function distributeTestsByWeight(testSuitePaths) {
6272
let specWeights = {};
6373
try {
@@ -101,5 +111,6 @@ function distributeTestsByWeight(testSuitePaths) {
101111

102112
module.exports = {
103113
getTestSuitePaths,
104-
distributeTestsByWeight
114+
distributeTestsByWeight,
115+
getMaxPathLenghtFrom
105116
};

0 commit comments

Comments
 (0)