Skip to content

Commit

Permalink
feat: use waitForSelector to prevent flakes
Browse files Browse the repository at this point in the history
  • Loading branch information
valerybugakov committed Apr 1, 2022
1 parent 8891364 commit b2bc64c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/web-functionality/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const handler = async (): Promise<void> => {
await runTests()
break
} catch (error) {
console.error(`Failed attempt ${index}:`, error)
console.error(`Failed attempt ${index + 1}:`, error)
if (index === 2) {
process.exit(error?.exitCode || 1)
}
Expand Down
8 changes: 6 additions & 2 deletions packages/web-functionality/src/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('Smoke tests', () => {

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

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

0 comments on commit b2bc64c

Please sign in to comment.