Skip to content

Commit

Permalink
Flexible column width based on spec path length
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicola committed Dec 3, 2023
1 parent 34d9873 commit d037e0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 12 additions & 1 deletion lib/test-suites.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -101,5 +111,6 @@ function distributeTestsByWeight(testSuitePaths) {

module.exports = {
getTestSuitePaths,
distributeTestsByWeight
distributeTestsByWeight,
getMaxPathLenghtFrom
};

0 comments on commit d037e0f

Please sign in to comment.