Skip to content

Corrupt JSON Response

Corrupt a JSON response and assert that the app renders a parse-safe error instead of crashing.

await injectChaos(page, {
seed: 42,
network: { corruptions: [{ urlPattern: '/api/profile', strategy: 'malformed-json', probability: 1 }] },
});
await page.goto('/profile');
await expect(page.locator('[data-testid="parse-error"]')).toBeVisible();
expect((await getChaosLog(page)).some((event) => event.type === 'network:corruption' && event.applied)).toBe(true);