Unverified Commit 3b8ce1a4 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Fix build-indicator test flaking (#83585)

## What?

Fixes the flaky build-indicator test to use `retry` instead of
`waitFor`. `waitFor` assumes something happens within x amount of time
but if that's slightly slower than that it fails the test even though
the test is not broken.
parent 7a43540b
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import fs from 'fs-extra' import fs from 'fs-extra'
import { join } from 'path' import { join } from 'path'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { findPort, launchApp, killApp, waitFor, check } from 'next-test-utils' import { findPort, launchApp, killApp, retry } from 'next-test-utils'
import stripAnsi from 'strip-ansi' import stripAnsi from 'strip-ansi'
const appDir = join(__dirname, '..') const appDir = join(__dirname, '..')
...@@ -47,12 +47,14 @@ describe('Build Activity Indicator', () => { ...@@ -47,12 +47,14 @@ describe('Build Activity Indicator', () => {
}) })
await fs.remove(configPath) await fs.remove(configPath)
await check( await retry(async () => {
() => stripAnsi(stderr), const content = stripAnsi(stderr)
new RegExp( expect(content).toMatch(
`Invalid "devIndicator.position" provided, expected one of top-left, top-right, bottom-left, bottom-right, received ttop-leff` new RegExp(
`Invalid "devIndicator.position" provided, expected one of top-left, top-right, bottom-left, bottom-right, received ttop-leff`
)
) )
) })
if (app) { if (app) {
await killApp(app) await killApp(app)
...@@ -76,9 +78,11 @@ describe('Build Activity Indicator', () => { ...@@ -76,9 +78,11 @@ describe('Build Activity Indicator', () => {
) )
await installCheckVisible(browser) await installCheckVisible(browser)
await browser.elementByCss('#to-a').click() await browser.elementByCss('#to-a').click()
await waitFor(500) await retry(async () => {
const wasVisible = await browser.eval('window.showedBuilder') const wasVisible = await browser.eval('window.showedBuilder')
expect(wasVisible).toBe(true) expect(wasVisible).toBe(true)
})
await browser.close() await browser.close()
}) })
} }
...@@ -98,10 +102,12 @@ describe('Build Activity Indicator', () => { ...@@ -98,10 +102,12 @@ describe('Build Activity Indicator', () => {
const newContent = origContent.replace('b', 'c') const newContent = origContent.replace('b', 'c')
await fs.writeFile(pagePath, newContent, 'utf8') await fs.writeFile(pagePath, newContent, 'utf8')
await waitFor(500)
const wasVisible = await browser.eval('window.showedBuilder')
expect(wasVisible).toBe(true) await retry(async () => {
const wasVisible = await browser.eval('window.showedBuilder')
expect(wasVisible).toBe(true)
})
await fs.writeFile(pagePath, origContent, 'utf8') await fs.writeFile(pagePath, origContent, 'utf8')
await browser.close() await browser.close()
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment