MCPcopy
hub / github.com/jestjs/jest / renderTime

Function renderTime

packages/jest-reporters/src/getSummary.ts:54–80  ·  view source on GitHub ↗
(runTime: number, estimatedTime: number, width: number)

Source from the content-addressed store, hash-verified

52}
53
54function renderTime(runTime: number, estimatedTime: number, width: number) {
55 // If we are more than one second over the estimated time, highlight it.
56 const renderedTime =
57 estimatedTime && runTime >= estimatedTime + 1
58 ? chalk.bold.yellow(formatTime(runTime, 0))
59 : formatTime(runTime, 0);
60 let time = `${chalk.bold('Time:')} ${renderedTime}`;
61 if (runTime < estimatedTime) {
62 time += `, estimated ${formatTime(estimatedTime, 0)}`;
63 }
64
65 // Only show a progress bar if the test run is actually going to take
66 // some time.
67 if (estimatedTime > 2 && runTime < estimatedTime && width) {
68 const availableWidth = Math.min(PROGRESS_BAR_WIDTH, width);
69 const length = Math.min(
70 Math.floor((runTime / estimatedTime) * availableWidth),
71 availableWidth,
72 );
73 if (availableWidth >= 2) {
74 time += `\n${chalk.green('█').repeat(length)}${chalk
75 .white('█')
76 .repeat(availableWidth - length)}`;
77 }
78 }
79 return time;
80}
81
82export default function getSummary(
83 aggregatedResults: AggregatedResult,

Callers 1

getSummaryFunction · 0.85

Calls 1

formatTimeFunction · 0.90

Tested by

no test coverage detected