File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed
scripts/junit-summary/util Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @linode/manager " : Tests
3+ ---
4+
5+ Fix Cypress test result summary duration accuracy ([ #12765 ] ( https://github.com/linode/manager/pull/12765 ) )
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ const getCommonJunitConfig = (
2727 testSuite : string ,
2828 config : Cypress . PluginConfigOptions
2929) => {
30+ const runnerIndex = Number ( config . env [ 'CY_TEST_SPLIT_RUN_INDEX' ] ) || 1 ;
31+
3032 if ( config . env [ envVarName ] ) {
3133 if ( ! config . reporterOptions ) {
3234 config . reporterOptions = { } ;
@@ -38,6 +40,9 @@ const getCommonJunitConfig = (
3840 testsuitesTitle : testSuiteName ,
3941 jenkinsMode : true ,
4042 suiteTitleSeparatedBy : '→' ,
43+ properties : {
44+ runner_index : runnerIndex ,
45+ } ,
4146 } ;
4247 }
4348 return config ;
Original file line number Diff line number Diff line change @@ -9,10 +9,32 @@ import type { TestResult } from '../results/test-result';
99 * @returns Length of time for all suites to run, in seconds.
1010 */
1111export const getTestLength = ( suites : TestSuites [ ] ) : number => {
12- const unroundedLength = suites . reduce ( ( acc : number , cur : TestSuites ) => {
13- return acc + ( cur . time ?? 0 ) ;
14- } , 0 ) ;
15- return Math . round ( unroundedLength * 1000 ) / 1000 ;
12+ const testDurations : { [ key : number ] : number } = suites . reduce ( ( acc : { [ key : number ] : number } , cur : TestSuites ) => {
13+ const suite = cur . testsuite ?. [ 0 ] ;
14+ if ( ! suite ) {
15+ return acc ;
16+ }
17+
18+ const runnerIndex = ( ( ) => {
19+ if ( ! suite . properties ) {
20+ return 1 ;
21+ }
22+ const indexProperty = suite . properties . find ( ( property ) => {
23+ return property . name === 'runner_index' ;
24+ } ) ;
25+
26+ if ( ! indexProperty ) {
27+ return 1 ;
28+ }
29+ return Number ( indexProperty . value ) ;
30+ } ) ( ) ;
31+
32+ acc [ runnerIndex ] = ( acc [ runnerIndex ] || 0 ) + ( cur . time ?? 0 ) ;
33+ return acc ;
34+ } , { } ) ;
35+
36+ const highestDuration = Math . max ( ...Object . values ( testDurations ) ) ;
37+ return Math . round ( highestDuration * 1000 ) / 1000 ;
1638} ;
1739
1840/**
You can’t perform that action at this time.
0 commit comments