@@ -39,7 +39,7 @@ if (!!JEST_TEST_BALANCER && !CI) {
39
39
) ;
40
40
}
41
41
42
- let JEST_TESTS ;
42
+ let JEST_TESTS : string [ ] | undefined ;
43
43
44
44
// prevents forkbomb as we don't want jest --listTests --json
45
45
// to reexec itself here
@@ -99,12 +99,12 @@ function getTestsForGroup(
99
99
const SUITE_P50_DURATION_MS = 1500 ;
100
100
101
101
// First, iterate over all of the tests we have stats for.
102
- for ( const test in testStats ) {
103
- if ( testStats [ test ] <= 0 ) {
102
+ Object . entries ( testStats ) . forEach ( ( [ test , duration ] ) => {
103
+ if ( duration <= 0 ) {
104
104
throw new Error ( `Test duration is <= 0 for ${ test } ` ) ;
105
105
}
106
- tests . set ( test , testStats [ test ] ) ;
107
- }
106
+ tests . set ( test , duration ) ;
107
+ } ) ;
108
108
// Then, iterate over all of the remaining tests and assign them a default duration.
109
109
for ( const test of allTests ) {
110
110
if ( tests . has ( test ) ) {
@@ -139,15 +139,15 @@ function getTestsForGroup(
139
139
// test that may exceed our target duration. For example, if target runtime for each group is
140
140
// 10 seconds, we have currently accounted for 9 seconds, and the next test is 5 seconds, we
141
141
// want to move that test to the next group so as to avoid a 40% imbalance.
142
- const peek = testsSortedByPath [ testsSortedByPath . length - 1 ] ;
142
+ const peek = testsSortedByPath [ testsSortedByPath . length - 1 ] ! ;
143
143
if ( duration + peek [ 1 ] > targetDuration && peek [ 1 ] > 30_000 ) {
144
144
break ;
145
145
}
146
146
const nextTest = testsSortedByPath . pop ( ) ;
147
147
if ( ! nextTest ) {
148
148
throw new TypeError ( 'Received falsy test' + JSON . stringify ( nextTest ) ) ;
149
149
}
150
- groups [ group ] . push ( nextTest [ 0 ] ) ;
150
+ groups [ group ] ! . push ( nextTest [ 0 ] ) ;
151
151
duration += nextTest [ 1 ] ;
152
152
}
153
153
}
@@ -159,7 +159,7 @@ function getTestsForGroup(
159
159
if ( ! nextTest ) {
160
160
throw new TypeError ( 'Received falsy test' + JSON . stringify ( nextTest ) ) ;
161
161
}
162
- groups [ i % 4 ] . push ( nextTest [ 0 ] ) ;
162
+ groups [ i % 4 ] ! . push ( nextTest [ 0 ] ) ;
163
163
i ++ ;
164
164
}
165
165
0 commit comments