@@ -10,7 +10,7 @@ import {
1010// Quality Gate Retries
1111const RETRIES_FOR_NEW_OR_CHANGED_TESTS = 4 ;
1212
13- function readTestResults ( TEST_RESULTS_PATH : string ) : TestRun | undefined {
13+ function readTestResults ( TEST_RESULTS_PATH : string ) : TestRun {
1414 const testSuiteName =
1515 process . env . TEST_SUITE_NAME || 'test-e2e-chrome-browserify' ;
1616
@@ -19,9 +19,12 @@ function readTestResults(TEST_RESULTS_PATH: string): TestRun | undefined {
1919 readFileSync ( TEST_RESULTS_PATH , 'utf8' ) ,
2020 ) ;
2121
22- const testRun : TestRun | undefined = testRuns . find (
22+ const testRun : TestRun = testRuns . find (
2323 ( run ) => run . name === testSuiteName ,
24- ) ;
24+ ) || { // If the file doesn't exist, return a dummy object to do the naïve split
25+ name : testSuiteName ,
26+ testFiles : [ ] ,
27+ } ;
2528
2629 return testRun ;
2730 } catch ( error ) {
@@ -82,31 +85,22 @@ export function splitTestsByTimings(
8285 TEST_RESULTS_FILE = `test/test-results/test-runs-${ process . env . SELENIUM_BROWSER } .json` ,
8386 } = process . env ;
8487
85- try {
86- const testRunLastTime = readTestResults ( TEST_RESULTS_FILE ) ;
87-
88- if ( testRunLastTime ) {
89- let testRunNew : TestRun = { name : testRunLastTime . name , testFiles : [ ] } ;
88+ const testRunLastTime = readTestResults ( TEST_RESULTS_FILE ) ;
89+ let testRunNew : TestRun = { name : testRunLastTime . name , testFiles : [ ] } ;
9090
91- testList . forEach ( ( path ) => {
92- const testFileLastTime = testRunLastTime . testFiles . find (
93- ( file ) => file . path === path ,
94- ) ;
95-
96- if ( testFileLastTime ) {
97- testRunNew . testFiles . push ( testFileLastTime ) ;
98- } else {
99- testRunNew . testFiles . push ( getNewBlankTestFile ( path ) ) ;
100- }
101- } ) ;
91+ testList . forEach ( ( path ) => {
92+ const testFileLastTime = testRunLastTime . testFiles . find (
93+ ( file ) => file . path === path ,
94+ ) ;
10295
103- return splitTests ( testRunNew , changedOrNewTests , totalChunks ) ;
96+ if ( testFileLastTime ) {
97+ testRunNew . testFiles . push ( testFileLastTime ) ;
98+ } else {
99+ testRunNew . testFiles . push ( getNewBlankTestFile ( path ) ) ;
104100 }
105- } catch ( error ) {
106- console . trace ( error ) ;
107- }
101+ } ) ;
108102
109- return [ ] ;
103+ return splitTests ( testRunNew , changedOrNewTests , totalChunks ) ;
110104}
111105
112106/**
0 commit comments