Playwright: Wait for Network Idle After Action
TypeScriptClick and wait for the matching API response instead of sleeping.
TypeScript · 5 lines
copied 19 times
const [response] = await Promise.all([
page.waitForResponse((r) => r.url().includes('/api/save') && r.ok()),
page.getByRole('button', { name: 'Save' }).click(),
]);
expect(await response.json()).toMatchObject({ status: 'ok' });
5
Fire
1
Learned something
2
Saved me time
2
Mind-blown
Sign in to react and star