Playwright: Wait for Network Idle After Action
TypeScriptClick and wait for the matching API response instead of sleeping.
TypeScript · 5 lines
copied 4 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' });
4
Fire
0
Learned something
2
Saved me time
1
Mind-blown
Sign in to react and star