You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Playwright page.waitForURL triggers faster than page contents change, it's like navigate first changes url and then react component rerenders, which makes test to fail. Any idea how to fix that?
import { expect, test } from "@playwright/test";
test("should edit user", async ({ context, browser, page }) => {
await page.goto(`/user/edit/${user.id}`);
await page.locator("input[name='nickname']").fill('x');
await page.getByText("save").click();
await page.waitForURL(`**/user/1/*`);
// await sleep(1000) works
await expect(await page.locator("h1").textContent()).toBe('x'); // error, h1 is `Edit`
});
Navigation code:
const navigate = useNavigate();
await navigate('user/1'); // on click
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Playwright
page.waitForURL
triggers faster than page contents change, it's likenavigate
first changes url and then react component rerenders, which makes test to fail. Any idea how to fix that?Navigation code:
Beta Was this translation helpful? Give feedback.
All reactions