Skip to content

Commit

Permalink
Merge pull request #4540 from Sebastian-Webster/tests-add-extra-wait
Browse files Browse the repository at this point in the history
Improved e2e test reliability
  • Loading branch information
junedchhipa authored Jun 25, 2024
2 parents a610a9d + ab72b93 commit fd8af2d
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions tests/e2e/samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,26 @@ async function processSample(page, sample, command) {

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

//Wait for all network requests to finish
await page.waitForNetworkIdle()
let wait;
do {
//Wait for all intervals in the page to have been cleared
await page.waitForFunction(() => window.activeIntervalCount === 0)

//Wait for all intervals in the page to have been cleared
await page.waitForFunction(() => window.activeIntervalCount === 0)
//Wait for all timers in the page to have all executed
await page.waitForFunction(() => window.activeTimerCount === 0)

//Wait for all timers in the page to have all executed
await page.waitForFunction(() => window.activeTimerCount === 0)
//Wait for the chart animation to end
await page.waitForFunction(() => chart.w.globals.animationEnded)

//Wait for the chart animation to end
await page.waitForFunction(() => chart.w.globals.animationEnded)
//Wait for all network requests to finish
await page.waitForNetworkIdle()

//After the network requests, timers, and intervals finish, if another request, timer, or interval is created then we need
//to wait for that to finish before continuing on.
wait = await page.evaluate(() => {
return !(window.activeIntervalCount === 0 && window.activeTimerCount === 0 && chart.w.globals.animationEnded)
})
} while (wait)

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

0 comments on commit fd8af2d

Please sign in to comment.