diff --git a/lib/cli.js b/lib/cli.js index 5e75ccf..f616e8c 100755 --- a/lib/cli.js +++ b/lib/cli.js @@ -6,7 +6,7 @@ const path = require('path'); const fs = require('fs-extra'); const { settings } = require('./settings'); -const { getTestSuitePaths, distributeTestsByWeight } = require('./test-suites'); +const { getTestSuitePaths, distributeTestsByWeight, getMaxPathLenghtFrom } = require('./test-suites'); const { formatTime, generateWeightsFile, @@ -55,7 +55,7 @@ async function start() { let table = new Table({ head: ['Spec', 'Time', 'Tests', 'Passing', 'Failing', 'Pending'], style: { head: ['blue'] }, - colWidths: [50, 8, 7, 9, 9, 9] + colWidths: [getMaxPathLenghtFrom(testSuitePaths), 10, 10, 10, 10, 10] }); let totalTests = 0; diff --git a/lib/test-suites.js b/lib/test-suites.js index f63f758..af73aca 100644 --- a/lib/test-suites.js +++ b/lib/test-suites.js @@ -58,6 +58,16 @@ async function getTestSuitePaths() { return fileList; } +function getMaxPathLenghtFrom(testSuitePaths) { + let maxLength = 10; + + for(let path of testSuitePaths){ + maxLength = Math.max(maxLength, path.length); + } + + return maxLength + 3; +} + function distributeTestsByWeight(testSuitePaths) { let specWeights = {}; try { @@ -101,5 +111,6 @@ function distributeTestsByWeight(testSuitePaths) { module.exports = { getTestSuitePaths, - distributeTestsByWeight + distributeTestsByWeight, + getMaxPathLenghtFrom };