Skip to content

Commit fd8af2d

Browse files
authored
Merge pull request #4540 from Sebastian-Webster/tests-add-extra-wait
Improved e2e test reliability
2 parents a610a9d + ab72b93 commit fd8af2d

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

tests/e2e/samples.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,26 @@ async function processSample(page, sample, command) {
9292

9393
await page.goto(`file://${htmlPath}`)
9494

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)
9799

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)
100102

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)
103105

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)
106115

107116
// Check that there are no console errors
108117
if (consoleErrors.length > 0) {

0 commit comments

Comments
 (0)