Skip to content

Nth Request Fails

Fail only the third matching request to exercise retry and partial-data behavior without making every request fail.

await injectChaos(page, {
seed: 42,
network: { failures: [{ urlPattern: '/api/search', statusCode: 503, probability: 1, onNth: 3 }] },
});
await page.goto('/search');
for (const term of ['a', 'ab', 'abc']) await page.fill('[name="q"]', term);
await expect(page.locator('[data-testid="retry-inline"]')).toBeVisible();
expect((await getChaosLog(page)).filter((event) => event.type === 'network:failure' && event.applied)).toHaveLength(1);