@@ -92,17 +92,26 @@ async function processSample(page, sample, command) {
92
92
93
93
await page . goto ( `file://${ htmlPath } ` )
94
94
95
- //Wait for all network requests to finish
96
- await page . waitForNetworkIdle ( )
95
+ let wait ;
96
+ do {
97
+ //Wait for all intervals in the page to have been cleared
98
+ await page . waitForFunction ( ( ) => window . activeIntervalCount === 0 )
97
99
98
- //Wait for all intervals in the page to have been cleared
99
- await page . waitForFunction ( ( ) => window . activeIntervalCount === 0 )
100
+ //Wait for all timers in the page to have all executed
101
+ await page . waitForFunction ( ( ) => window . activeTimerCount === 0 )
100
102
101
- //Wait for all timers in the page to have all executed
102
- await page . waitForFunction ( ( ) => window . activeTimerCount === 0 )
103
+ //Wait for the chart animation to end
104
+ await page . waitForFunction ( ( ) => chart . w . globals . animationEnded )
103
105
104
- //Wait for the chart animation to end
105
- await page . waitForFunction ( ( ) => chart . w . globals . animationEnded )
106
+ //Wait for all network requests to finish
107
+ await page . waitForNetworkIdle ( )
108
+
109
+ //After the network requests, timers, and intervals finish, if another request, timer, or interval is created then we need
110
+ //to wait for that to finish before continuing on.
111
+ wait = await page . evaluate ( ( ) => {
112
+ return ! ( window . activeIntervalCount === 0 && window . activeTimerCount === 0 && chart . w . globals . animationEnded )
113
+ } )
114
+ } while ( wait )
106
115
107
116
// Check that there are no console errors
108
117
if ( consoleErrors . length > 0 ) {
0 commit comments