Skip to content

Commit

Permalink
test: Fix flaky e2e test (#2476)
Browse files Browse the repository at this point in the history
  • Loading branch information
promer94 committed Mar 5, 2023
1 parent 851eb98 commit 4650520
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions e2e/test/initial-render.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

const sleep = async (ms: number) =>
new Promise(resolve => setTimeout(resolve, ms))

test.describe('rendering', () => {
test('should only render once if the result of swr is not used', async ({
page
Expand All @@ -8,6 +12,7 @@ test.describe('rendering', () => {
await page.exposeFunction('onRender', (msg: any) => log.push(msg))
await page.goto('./initial-render', { waitUntil: 'commit' })
await expect(page.getByText('SWRTest')).toBeVisible()
await sleep(1200)
expect(log).toHaveLength(1)
})
})

0 comments on commit 4650520

Please sign in to comment.