/
githubmirror
/
react-hook-form
Обзор
Документация
Войти
/
githubmirror
/
react-hook-form
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
e2e/utils.ts
42 строки
2 KB
Bill
🥗 migrate to playwright & fix delay error feature (#13589)
11 июл 2026, 12:39
Не верифицирован
11 июл 2026, 12:39
11bd6df
Код
Авторство
О чём код?
import { expect, type Locator } from '@playwright/test'; /** * Playwright's locator.pressSequentially() repositions the cursor to the * start of the field's existing value on each call (unlike Cypress's type(), * which continues from wherever the cursor last was). Explicitly moving to * the end first makes repeated typing into the same field append correctly. */ export async function type(locator: Locator, text: string) { await locator.focus(); await locator.press('End'); await locator.pressSequentially(text); } /** * For long, async-validation-heavy interaction sequences, the exact * `#renderCount` value isn't deterministic run-to-run under Playwright (it * settles within a range depending on scheduling/microtask timing) even * though the underlying value stops changing well within the timeout. This * asserts a bounded range instead of an exact count, preserving the original * test's intent (catch a real over-rendering regression) without flaking on * harmless timing jitter. Bounds should be set from repeated local runs * (see e2e/basic.spec.ts for the range derivation), not guessed. */ export async function expectRenderCountInRange( locator: Locator, min: number, max: number, ) { let previous = -1; await expect .poll(async () => { const current = Number(await locator.textContent()); const stable = current === previous; previous = current; return stable; }) .toBe(true); expect(previous).toBeGreaterThanOrEqual(min); expect(previous).toBeLessThanOrEqual(max); }