mirror of
https://github.com/supabase/supabase.git
synced 2026-05-06 17:00:27 -04:00
b168ec364a
## Problem Some tests rely on hard coded timeouts. That makes them - brittle if the timeout is not long enough - take longer than necessary if the timeout is too long ## Solution - Rely on playwright `expect` retries when possible - Rely on UI updates when possible
22 lines
505 B
TypeScript
22 lines
505 B
TypeScript
import { expect, type Page } from '@playwright/test'
|
|
|
|
export const expectClipboardValue = ({
|
|
page,
|
|
value,
|
|
exact = false,
|
|
timeout = 2000,
|
|
}: {
|
|
page: Page
|
|
value: string
|
|
exact?: boolean
|
|
timeout?: number
|
|
}) =>
|
|
expect(async () => {
|
|
await using handle = await page.evaluateHandle(() => navigator.clipboard.readText())
|
|
if (exact) {
|
|
expect(await handle.jsonValue()).toEqual(value)
|
|
} else {
|
|
expect(await handle.jsonValue()).toContain(value)
|
|
}
|
|
}).toPass({ timeout })
|