Skip to content

Commit b2bc64c

Browse files
committed
feat: use waitForSelector to prevent flakes
1 parent 8891364 commit b2bc64c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/web-functionality/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const handler = async (): Promise<void> => {
2626
await runTests()
2727
break
2828
} catch (error) {
29-
console.error(`Failed attempt ${index}:`, error)
29+
console.error(`Failed attempt ${index + 1}:`, error)
3030
if (index === 2) {
3131
process.exit(error?.exitCode || 1)
3232
}

packages/web-functionality/src/smoke.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe('Smoke tests', () => {
99

1010
it('successful runs a search', async () => {
1111
// Update search input
12+
await page.waitForSelector('.test-query-input textarea')
1213
await expect(page).toFill(
1314
'.test-query-input textarea',
1415
'repo:^github.com/sourcegraph/smoke-tests-test-repository$'
@@ -18,6 +19,9 @@ describe('Smoke tests', () => {
1819
await expect(page).toClick('.test-search-button')
1920

2021
// Expect results count is shown correctly
21-
await expect(page).toMatchElement('[data-testid="streaming-progress-count"]', { text: '1 result' })
22-
}, 5000) // Bigger timeout is required to avoid flakes. Default is 500ms.
22+
await page.waitForSelector('[data-testid="streaming-progress-count"]')
23+
await expect(page).toMatchElement('[data-testid="streaming-progress-count"]', {
24+
text: '1 result',
25+
})
26+
})
2327
})

0 commit comments

Comments
 (0)