[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D8HFZA1K0NFKCMC3KX1ZAR":3,"skill-same:01M7D8HFZA1K0NFKCMC3KX1ZAR":81},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":14,"repositoryHtmlUrl":62,"repositoryHomepageUrl":6,"ownerHtmlUrl":63,"ownerBlogUrl":64,"ownerDescription":65,"updatedAt":66,"install":67,"resources":80},"01M7D8HFZA1K0NFKCMC3KX1ZAR","Error Boundary Tester",null,"Validate error boundary implementations in React and other frameworks ensuring graceful degradation, proper fallback UI rendering, and error recovery flows","GrupoANDevelopment-m\u002Falberto-ai","GrupoANDevelopment-m","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257455179?v=4","01M7D69X2N2KEVN0SJF6WGM6SH","Antônio  Ndombe","01M7D69X3P5JTT8H8S904N3888",0,"MIT","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Ferror-boundary-tester\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: Error Boundary Tester\ndescription: Validate error boundary implementations in React and other frameworks ensuring graceful degradation, proper fallback UI rendering, and error recovery flows\nversion: 1.0.0\nauthor: Pramod\nlicense: MIT\ntags: [error-boundary, error-handling, graceful-degradation, fallback-ui, react-error-boundary, crash-recovery, resilience]\ntestingTypes: [e2e, unit]\nframeworks: [playwright, jest, vitest]\nlanguages: [typescript, javascript]\ndomains: [web]\nagents: [claude-code, cursor, github-copilot, windsurf, codex, aider, continue, cline, zed, bolt, gemini-cli, amp]\n---\n\n# Error Boundary Tester Skill\n\nYou are an expert QA automation engineer specializing in error boundary and fault tolerance testing. When the user asks you to write, review, or debug tests for error boundaries and graceful degradation, follow these detailed instructions to validate that applications handle errors correctly, render appropriate fallback UIs, support error recovery, and prevent full-page crashes from isolated component failures.\n\n## Core Principles\n\n1. **Errors are inevitable, crashes are not** -- Every component will eventually encounter an error. Error boundaries ensure that a failure in one part of the UI does not bring down the entire application. Test that each error boundary contains failures within its scope.\n2. **Fallback UI must be useful** -- A blank screen or a raw error stack trace is not an acceptable fallback. Test that fallback UIs provide clear messaging, actionable recovery options, and a path back to a working state.\n3. **Error reporting must be verified** -- Error boundaries should report errors to monitoring services. Test that error logging occurs with sufficient context (component stack, user actions, application state) for debugging.\n4. **Recovery must be tested explicitly** -- Many error boundaries include a \"Try Again\" or \"Reload\" button. Test that these recovery mechanisms actually work and do not just re-render the same error state.\n5. **Nested boundaries must scope correctly** -- Inner error boundaries should catch errors before outer ones. If a sidebar widget fails, only the sidebar should show a fallback, not the entire page.\n6. **Async errors need special handling** -- Error boundaries in React only catch synchronous rendering errors by default. Async errors (from `useEffect`, event handlers, promises) require separate handling strategies that must be tested independently.\n\n## Project Structure\n\nOrganize error boundary test projects with this structure:\n\n```\ntests\u002F\n  error-boundaries\u002F\n    unit\u002F\n      error-boundary-component.test.tsx\n      fallback-ui.test.tsx\n      error-reporter.test.ts\n      recovery-flow.test.tsx\n    e2e\u002F\n      component-crash.spec.ts\n      nested-boundary.spec.ts\n      full-page-crash.spec.ts\n      chunk-load-failure.spec.ts\n      network-error.spec.ts\n    integration\u002F\n      error-logging.spec.ts\n      error-recovery.spec.ts\n  helpers\u002F\n    error-injector.ts\n    crash-component.tsx\n    boundary-test-utils.ts\n  fixtures\u002F\n    error-scenarios.fixture.ts\n  mocks\u002F\n    error-reporter.mock.ts\nplaywright.config.ts\nvitest.config.ts\n```\n\n## React Error Boundary Unit Testing\n\n### Testing the Error Boundary Component Itself\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Ferror-boundary-component.test.tsx\nimport { render, screen, fireEvent } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi, beforeEach } from 'vitest';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\n\n\u002F\u002F A component that throws on demand\nfunction CrashingComponent({ shouldCrash }: { shouldCrash: boolean }) {\n  if (shouldCrash) {\n    throw new Error('Intentional test crash');\n  }\n  return \u003Cdiv data-testid=\"healthy-content\">Everything is working\u003C\u002Fdiv>;\n}\n\n\u002F\u002F A component that throws during render\nfunction AlwaysCrashes(): JSX.Element {\n  throw new Error('Component always crashes');\n}\n\n\u002F\u002F A component that throws a specific error type\nfunction TypeErrorComponent(): JSX.Element {\n  const obj: Record\u003Cstring, unknown> = {};\n  \u002F\u002F Force a TypeError at runtime\n  return \u003Cdiv>{(obj as { nested: { value: string } }).nested.value}\u003C\u002Fdiv>;\n}\n\ndescribe('ErrorBoundary Component', () => {\n  let consoleErrorSpy: ReturnType\u003Ctypeof vi.spyOn>;\n\n  beforeEach(() => {\n    \u002F\u002F Suppress React's console.error for error boundaries in tests\n    consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});\n  });\n\n  test('renders children when no error occurs', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error occurred\u003C\u002Fdiv>}>\n        \u003CCrashingComponent shouldCrash={false} \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('healthy-content')).toBeInTheDocument();\n    expect(screen.queryByText('Error occurred')).not.toBeInTheDocument();\n  });\n\n  test('renders fallback UI when child component throws', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"fallback\">Something went wrong\u003C\u002Fdiv>}>\n        \u003CAlwaysCrashes \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('fallback')).toBeInTheDocument();\n    expect(screen.getByText('Something went wrong')).toBeInTheDocument();\n    expect(screen.queryByTestId('healthy-content')).not.toBeInTheDocument();\n  });\n\n  test('calls onError callback with error and component stack', () => {\n    const onError = vi.fn();\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv>Error\u003C\u002Fdiv>}\n        onError={onError}\n      >\n        \u003CAlwaysCrashes \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(onError).toHaveBeenCalledTimes(1);\n    expect(onError).toHaveBeenCalledWith(\n      expect.objectContaining({\n        message: 'Component always crashes',\n      }),\n      expect.objectContaining({\n        componentStack: expect.any(String),\n      })\n    );\n  });\n\n  test('catches TypeError from nested rendering', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"type-error-fallback\">Type error caught\u003C\u002Fdiv>}>\n        \u003CTypeErrorComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('type-error-fallback')).toBeInTheDocument();\n  });\n\n  test('different error boundaries catch errors independently', () => {\n    render(\n      \u003Cdiv>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"sidebar-fallback\">Sidebar error\u003C\u002Fdiv>}>\n          \u003CAlwaysCrashes \u002F>\n        \u003C\u002FErrorBoundary>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"main-fallback\">Main error\u003C\u002Fdiv>}>\n          \u003CCrashingComponent shouldCrash={false} \u002F>\n        \u003C\u002FErrorBoundary>\n      \u003C\u002Fdiv>\n    );\n\n    \u002F\u002F Sidebar should show fallback\n    expect(screen.getByTestId('sidebar-fallback')).toBeInTheDocument();\n    \u002F\u002F Main should show healthy content\n    expect(screen.getByTestId('healthy-content')).toBeInTheDocument();\n    \u002F\u002F Main fallback should NOT be shown\n    expect(screen.queryByTestId('main-fallback')).not.toBeInTheDocument();\n  });\n});\n```\n\n### Testing Fallback UI Content\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Ffallback-ui.test.tsx\nimport { render, screen } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi } from 'vitest';\nimport { ErrorFallback } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-fallback';\n\ndescribe('ErrorFallback Component', () => {\n  test('displays user-friendly error message', () => {\n    render(\n      \u003CErrorFallback\n        error={new Error('API request failed')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    \u002F\u002F Should show a friendly message, not the raw error\n    expect(screen.getByRole('heading')).toHaveTextContent(\u002Fsomething went wrong\u002Fi);\n    expect(screen.queryByText('API request failed')).not.toBeInTheDocument();\n  });\n\n  test('shows recovery button', () => {\n    const resetFn = vi.fn();\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={resetFn}\n      \u002F>\n    );\n\n    const retryButton = screen.getByRole('button', { name: \u002Ftry again\u002Fi });\n    expect(retryButton).toBeInTheDocument();\n  });\n\n  test('recovery button triggers resetErrorBoundary', async () => {\n    const resetFn = vi.fn();\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={resetFn}\n      \u002F>\n    );\n\n    const retryButton = screen.getByRole('button', { name: \u002Ftry again\u002Fi });\n    await retryButton.click();\n\n    expect(resetFn).toHaveBeenCalledTimes(1);\n  });\n\n  test('provides a link to navigate home as escape hatch', () => {\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    const homeLink = screen.getByRole('link', { name: \u002Fgo home|return home\u002Fi });\n    expect(homeLink).toHaveAttribute('href', '\u002F');\n  });\n\n  test('fallback UI is accessible', () => {\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    \u002F\u002F Should have proper ARIA attributes\n    const alertRegion = screen.getByRole('alert');\n    expect(alertRegion).toBeInTheDocument();\n\n    \u002F\u002F Retry button should be focusable\n    const retryButton = screen.getByRole('button', { name: \u002Ftry again\u002Fi });\n    expect(retryButton).not.toHaveAttribute('tabindex', '-1');\n  });\n\n  test('does not expose stack trace in production mode', () => {\n    const originalEnv = process.env.NODE_ENV;\n    process.env.NODE_ENV = 'production';\n\n    render(\n      \u003CErrorFallback\n        error={new Error('Sensitive error details here')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    expect(screen.queryByText(\u002FSensitive error details\u002F)).not.toBeInTheDocument();\n    expect(screen.queryByText(\u002Fat \u002F)).not.toBeInTheDocument(); \u002F\u002F No stack traces\n\n    process.env.NODE_ENV = originalEnv;\n  });\n});\n```\n\n## Error Injection for E2E Testing\n\n### Forced Error Injection via Playwright\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fcomponent-crash.spec.ts\nimport { test, expect, Page } from '@playwright\u002Ftest';\n\nasync function injectRenderError(page: Page, componentSelector: string): Promise\u003Cvoid> {\n  await page.evaluate((selector) => {\n    const element = document.querySelector(selector);\n    if (!element) throw new Error(`Element not found: ${selector}`);\n\n    \u002F\u002F Inject an error-throwing element that React will try to render\n    const errorDiv = document.createElement('div');\n    errorDiv.setAttribute('data-crash-injected', 'true');\n\n    \u002F\u002F Override innerHTML to force a React reconciliation error\n    Object.defineProperty(errorDiv, 'textContent', {\n      get() {\n        throw new Error('Injected render error for testing');\n      },\n    });\n\n    element.appendChild(errorDiv);\n  }, componentSelector);\n}\n\ntest.describe('Component Crash Recovery (E2E)', () => {\n  test('sidebar crash should not affect main content', async ({ page }) => {\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Verify both sidebar and main content are initially visible\n    await expect(page.locator('[data-testid=\"sidebar\"]')).toBeVisible();\n    await expect(page.locator('[data-testid=\"main-content\"]')).toBeVisible();\n\n    \u002F\u002F Simulate a JavaScript error in the sidebar component\n    await page.evaluate(() => {\n      \u002F\u002F Dispatch a custom event that triggers an error in the sidebar\n      window.dispatchEvent(\n        new CustomEvent('__test_inject_error', {\n          detail: { component: 'sidebar' },\n        })\n      );\n    });\n\n    \u002F\u002F Main content should still be functional\n    await expect(page.locator('[data-testid=\"main-content\"]')).toBeVisible();\n\n    \u002F\u002F Sidebar should show error fallback\n    const sidebarFallback = page.locator('[data-testid=\"sidebar-error-fallback\"]');\n    await expect(sidebarFallback).toBeVisible();\n\n    \u002F\u002F Sidebar fallback should have a retry option\n    const retryButton = sidebarFallback.locator('button:has-text(\"Retry\")');\n    await expect(retryButton).toBeVisible();\n  });\n\n  test('clicking retry should recover from error', async ({ page }) => {\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Trigger a recoverable error\n    await page.evaluate(() => {\n      window.dispatchEvent(\n        new CustomEvent('__test_inject_error', {\n          detail: { component: 'widget', recoverable: true },\n        })\n      );\n    });\n\n    \u002F\u002F Verify fallback is shown\n    const fallback = page.locator('[data-testid=\"widget-error-fallback\"]');\n    await expect(fallback).toBeVisible();\n\n    \u002F\u002F Click retry\n    await fallback.locator('button:has-text(\"Try Again\")').click();\n\n    \u002F\u002F Verify the component recovered\n    await expect(page.locator('[data-testid=\"widget-content\"]')).toBeVisible();\n    await expect(fallback).not.toBeVisible();\n  });\n});\n```\n\n### Testing Error Boundaries with Network Failures\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fnetwork-error.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Network Error Boundaries', () => {\n  test('should show error boundary when API request fails', async ({ page }) => {\n    \u002F\u002F Intercept API calls and force them to fail\n    await page.route('**\u002Fapi\u002Fdashboard\u002Fstats', (route) => {\n      route.abort('connectionrefused');\n    });\n\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F The stats component should show its error boundary\n    const statsError = page.locator('[data-testid=\"stats-error\"]');\n    await expect(statsError).toBeVisible();\n    await expect(statsError).toContainText(\u002Funable to load|failed to load\u002Fi);\n\n    \u002F\u002F Other dashboard components should still work\n    await expect(page.locator('[data-testid=\"recent-activity\"]')).toBeVisible();\n  });\n\n  test('should recover when API becomes available again', async ({ page }) => {\n    let requestCount = 0;\n\n    \u002F\u002F Fail the first request, succeed on retry\n    await page.route('**\u002Fapi\u002Fdashboard\u002Fstats', (route) => {\n      requestCount++;\n      if (requestCount \u003C= 1) {\n        route.abort('connectionrefused');\n      } else {\n        route.fulfill({\n          status: 200,\n          contentType: 'application\u002Fjson',\n          body: JSON.stringify({ total: 42, active: 10 }),\n        });\n      }\n    });\n\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Error should be showing\n    const statsError = page.locator('[data-testid=\"stats-error\"]');\n    await expect(statsError).toBeVisible();\n\n    \u002F\u002F Click retry\n    await statsError.locator('button:has-text(\"Retry\")').click();\n\n    \u002F\u002F Stats should now display correctly\n    await expect(page.locator('[data-testid=\"stats-content\"]')).toBeVisible();\n    await expect(page.locator('[data-testid=\"stats-total\"]')).toContainText('42');\n  });\n\n  test('should handle 500 server errors gracefully', async ({ page }) => {\n    await page.route('**\u002Fapi\u002Fposts', (route) => {\n      route.fulfill({\n        status: 500,\n        contentType: 'application\u002Fjson',\n        body: JSON.stringify({ error: 'Internal Server Error' }),\n      });\n    });\n\n    await page.goto('\u002Fposts');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Should show a user-friendly error, not a raw 500 message\n    await expect(page.locator('[role=\"alert\"]')).toBeVisible();\n    await expect(page.locator('[role=\"alert\"]')).not.toContainText('500');\n    await expect(page.locator('[role=\"alert\"]')).not.toContainText('Internal Server Error');\n  });\n});\n```\n\n## Nested Error Boundary Scoping\n\nTesting that inner boundaries catch errors before outer boundaries is critical for maintaining partial functionality during failures.\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Fnested-boundary.test.tsx\nimport { render, screen } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi } from 'vitest';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\n\nfunction CrashingWidget(): JSX.Element {\n  throw new Error('Widget crashed');\n}\n\nfunction HealthyWidget(): JSX.Element {\n  return \u003Cdiv data-testid=\"healthy-widget\">Working widget\u003C\u002Fdiv>;\n}\n\ndescribe('Nested Error Boundary Scoping', () => {\n  const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});\n\n  test('inner boundary catches error before outer boundary', () => {\n    const innerOnError = vi.fn();\n    const outerOnError = vi.fn();\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv data-testid=\"outer-fallback\">Outer error\u003C\u002Fdiv>}\n        onError={outerOnError}\n      >\n        \u003Cdiv data-testid=\"page-layout\">\n          \u003CErrorBoundary\n            fallback={\u003Cdiv data-testid=\"inner-fallback\">Inner error\u003C\u002Fdiv>}\n            onError={innerOnError}\n          >\n            \u003CCrashingWidget \u002F>\n          \u003C\u002FErrorBoundary>\n          \u003CHealthyWidget \u002F>\n        \u003C\u002Fdiv>\n      \u003C\u002FErrorBoundary>\n    );\n\n    \u002F\u002F Inner fallback should be shown\n    expect(screen.getByTestId('inner-fallback')).toBeInTheDocument();\n    \u002F\u002F Healthy widget should still be visible\n    expect(screen.getByTestId('healthy-widget')).toBeInTheDocument();\n    \u002F\u002F Outer fallback should NOT be shown\n    expect(screen.queryByTestId('outer-fallback')).not.toBeInTheDocument();\n    \u002F\u002F Page layout should still be intact\n    expect(screen.getByTestId('page-layout')).toBeInTheDocument();\n\n    \u002F\u002F Inner onError should be called, outer should NOT\n    expect(innerOnError).toHaveBeenCalledTimes(1);\n    expect(outerOnError).not.toHaveBeenCalled();\n  });\n\n  test('outer boundary catches when there is no inner boundary', () => {\n    const outerOnError = vi.fn();\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv data-testid=\"outer-fallback\">Page error\u003C\u002Fdiv>}\n        onError={outerOnError}\n      >\n        \u003CCrashingWidget \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('outer-fallback')).toBeInTheDocument();\n    expect(outerOnError).toHaveBeenCalledTimes(1);\n  });\n\n  test('multiple sibling boundaries are independent', () => {\n    render(\n      \u003Cdiv>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"boundary-a-fallback\">A failed\u003C\u002Fdiv>}>\n          \u003CCrashingWidget \u002F>\n        \u003C\u002FErrorBoundary>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"boundary-b-fallback\">B failed\u003C\u002Fdiv>}>\n          \u003CHealthyWidget \u002F>\n        \u003C\u002FErrorBoundary>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"boundary-c-fallback\">C failed\u003C\u002Fdiv>}>\n          \u003CCrashingWidget \u002F>\n        \u003C\u002FErrorBoundary>\n      \u003C\u002Fdiv>\n    );\n\n    \u002F\u002F A and C should show fallbacks\n    expect(screen.getByTestId('boundary-a-fallback')).toBeInTheDocument();\n    expect(screen.getByTestId('boundary-c-fallback')).toBeInTheDocument();\n    \u002F\u002F B should show healthy content\n    expect(screen.getByTestId('healthy-widget')).toBeInTheDocument();\n    expect(screen.queryByTestId('boundary-b-fallback')).not.toBeInTheDocument();\n  });\n});\n```\n\n## Error Logging and Reporting Verification\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Ferror-reporter.test.ts\nimport { describe, test, expect, vi, beforeEach } from 'vitest';\nimport { render } from '@testing-library\u002Freact';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\nimport * as errorReporter from '..\u002F..\u002Fsrc\u002Flib\u002Ferror-reporter';\n\nfunction CrashingComponent(): JSX.Element {\n  throw new Error('Crash for reporting test');\n}\n\ndescribe('Error Reporting from Boundaries', () => {\n  let reportSpy: ReturnType\u003Ctypeof vi.spyOn>;\n\n  beforeEach(() => {\n    reportSpy = vi.spyOn(errorReporter, 'reportError').mockResolvedValue(undefined);\n    vi.spyOn(console, 'error').mockImplementation(() => {});\n  });\n\n  test('error boundary should report error to monitoring service', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error\u003C\u002Fdiv>}>\n        \u003CCrashingComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(reportSpy).toHaveBeenCalledTimes(1);\n    expect(reportSpy).toHaveBeenCalledWith(\n      expect.objectContaining({\n        message: 'Crash for reporting test',\n      }),\n      expect.objectContaining({\n        componentStack: expect.any(String),\n      })\n    );\n  });\n\n  test('error report should include component stack trace', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error\u003C\u002Fdiv>}>\n        \u003Cdiv>\n          \u003Csection>\n            \u003CCrashingComponent \u002F>\n          \u003C\u002Fsection>\n        \u003C\u002Fdiv>\n      \u003C\u002FErrorBoundary>\n    );\n\n    const [, errorInfo] = reportSpy.mock.calls[0];\n    expect(errorInfo.componentStack).toContain('CrashingComponent');\n  });\n\n  test('error report should not include PII', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error\u003C\u002Fdiv>}>\n        \u003CCrashingComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    const [error, errorInfo] = reportSpy.mock.calls[0];\n    const reportString = JSON.stringify({ error: error.message, ...errorInfo });\n\n    \u002F\u002F Ensure no emails, tokens, or other PII in the report\n    expect(reportString).not.toMatch(\u002F@.*\\.\u002F);\n    expect(reportString).not.toMatch(\u002FBearer\\s+\u002F);\n    expect(reportString).not.toMatch(\u002Fpassword\u002Fi);\n  });\n});\n```\n\n## Async Error Handling\n\nReact error boundaries do not catch errors in event handlers, async functions, or `setTimeout` callbacks. These require separate handling.\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Fasync-error-handling.test.tsx\nimport { render, screen, fireEvent, waitFor } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi } from 'vitest';\nimport { useState } from 'react';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\n\nfunction AsyncCrashingComponent() {\n  const [error, setError] = useState\u003CError | null>(null);\n\n  const handleClick = async () => {\n    try {\n      const response = await fetch('\u002Fapi\u002Fdata');\n      if (!response.ok) throw new Error('API failed');\n      const data = await response.json();\n      return data;\n    } catch (err) {\n      setError(err as Error);\n    }\n  };\n\n  if (error) {\n    throw error; \u002F\u002F Re-throw to be caught by error boundary\n  }\n\n  return (\n    \u003Cbutton data-testid=\"trigger\" onClick={handleClick}>\n      Load Data\n    \u003C\u002Fbutton>\n  );\n}\n\ndescribe('Async Error Handling', () => {\n  vi.spyOn(console, 'error').mockImplementation(() => {});\n\n  test('async errors should be caught by error boundary when re-thrown via state', async () => {\n    \u002F\u002F Mock the fetch to fail\n    global.fetch = vi.fn().mockRejectedValue(new Error('Network error'));\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv data-testid=\"async-fallback\">Async error caught\u003C\u002Fdiv>}\n      >\n        \u003CAsyncCrashingComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    \u002F\u002F Trigger the async operation\n    fireEvent.click(screen.getByTestId('trigger'));\n\n    \u002F\u002F Wait for the error boundary to render the fallback\n    await waitFor(() => {\n      expect(screen.getByTestId('async-fallback')).toBeInTheDocument();\n    });\n  });\n});\n```\n\n## Chunk Loading Failure Handling\n\nDynamic imports can fail when deployment invalidates old chunks. This is a common production error that error boundaries must handle.\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fchunk-load-failure.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Chunk Loading Failure', () => {\n  test('should show error boundary when a lazy-loaded chunk fails', async ({ page }) => {\n    \u002F\u002F Intercept chunk requests and make them fail\n    await page.route('**\u002F*.chunk.js', (route) => {\n      route.fulfill({\n        status: 404,\n        body: 'Not Found',\n      });\n    });\n\n    await page.goto('\u002F');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Navigate to a route that uses lazy loading\n    await page.click('a[href=\"\u002Fsettings\"]');\n\n    \u002F\u002F Should show a meaningful error, not a blank page\n    await expect(\n      page.locator('[role=\"alert\"], [data-testid=\"chunk-error\"]')\n    ).toBeVisible({ timeout: 10000 });\n\n    \u002F\u002F Should offer a way to recover (typically a page reload)\n    const reloadButton = page.locator(\n      'button:has-text(\"Reload\"), button:has-text(\"Refresh\")'\n    );\n    await expect(reloadButton).toBeVisible();\n  });\n\n  test('should auto-retry chunk loading before showing error', async ({ page }) => {\n    let chunkRequestCount = 0;\n\n    await page.route('**\u002Fsettings.chunk.js', (route) => {\n      chunkRequestCount++;\n      if (chunkRequestCount \u003C= 2) {\n        \u002F\u002F Fail first 2 attempts\n        route.fulfill({ status: 500, body: 'Server Error' });\n      } else {\n        \u002F\u002F Succeed on third attempt\n        route.continue();\n      }\n    });\n\n    await page.goto('\u002F');\n    await page.click('a[href=\"\u002Fsettings\"]');\n\n    \u002F\u002F The page should eventually load after retries\n    await expect(\n      page.locator('[data-testid=\"settings-page\"]')\n    ).toBeVisible({ timeout: 15000 });\n\n    \u002F\u002F Should have retried at least once\n    expect(chunkRequestCount).toBeGreaterThan(1);\n  });\n\n  test('stale deployment chunk failure should suggest page refresh', async ({ page }) => {\n    \u002F\u002F Simulate a deployment scenario where chunk hashes have changed\n    await page.route('**\u002F*.[a-f0-9]*.js', (route) => {\n      if (route.request().url().includes('old-hash')) {\n        route.fulfill({ status: 404, body: 'Not Found' });\n      } else {\n        route.continue();\n      }\n    });\n\n    await page.goto('\u002F');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Check that the error message mentions updating or refreshing\n    const errorMessage = page.locator('[role=\"alert\"]');\n    if (await errorMessage.isVisible()) {\n      const text = await errorMessage.textContent();\n      expect(text).toMatch(\u002Frefresh|reload|update|new version\u002Fi);\n    }\n  });\n});\n```\n\n## Configuration\n\n### Vitest Configuration for Error Boundary Tests\n\n```typescript\n\u002F\u002F vitest.config.ts\nimport { defineConfig } from 'vitest\u002Fconfig';\nimport react from '@vitejs\u002Fplugin-react';\n\nexport default defineConfig({\n  plugins: [react()],\n  test: {\n    environment: 'jsdom',\n    setupFiles: ['.\u002Ftests\u002Fsetup.ts'],\n    globals: true,\n    include: [\n      'tests\u002Ferror-boundaries\u002Funit\u002F**\u002F*.test.{ts,tsx}',\n      'tests\u002Ferror-boundaries\u002Fintegration\u002F**\u002F*.test.{ts,tsx}',\n    ],\n    coverage: {\n      include: [\n        'src\u002Fcomponents\u002Ferror-boundary\u002F**',\n        'src\u002Fcomponents\u002Ferror-fallback\u002F**',\n        'src\u002Flib\u002Ferror-reporter.*',\n      ],\n      thresholds: {\n        statements: 90,\n        branches: 85,\n        functions: 90,\n        lines: 90,\n      },\n    },\n  },\n});\n```\n\n### Playwright Configuration for Error Boundary E2E Tests\n\n```typescript\n\u002F\u002F playwright.config.ts\nimport { defineConfig, devices } from '@playwright\u002Ftest';\n\nexport default defineConfig({\n  testDir: '.\u002Ftests\u002Ferror-boundaries\u002Fe2e',\n  fullyParallel: true,\n  retries: 1,\n  reporter: [\n    ['html', { open: 'never' }],\n    ['json', { outputFile: 'error-boundary-results.json' }],\n  ],\n  use: {\n    baseURL: process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000',\n    trace: 'on-first-retry',\n    screenshot: 'only-on-failure',\n    video: 'on-first-retry',\n  },\n  projects: [\n    {\n      name: 'error-boundaries-chrome',\n      use: { ...devices['Desktop Chrome'] },\n    },\n    {\n      name: 'error-boundaries-firefox',\n      use: { ...devices['Desktop Firefox'] },\n    },\n    {\n      name: 'error-boundaries-mobile',\n      use: { ...devices['iPhone 14'] },\n    },\n  ],\n});\n```\n\n### Test Setup File\n\n```typescript\n\u002F\u002F tests\u002Fsetup.ts\nimport '@testing-library\u002Fjest-dom';\nimport { cleanup } from '@testing-library\u002Freact';\nimport { afterEach, vi } from 'vitest';\n\nafterEach(() => {\n  cleanup();\n  vi.restoreAllMocks();\n});\n\n\u002F\u002F Suppress React error boundary console.error in test output\n\u002F\u002F while still allowing test assertions on error reporting\nconst originalConsoleError = console.error;\nconsole.error = (...args: unknown[]) => {\n  const message = typeof args[0] === 'string' ? args[0] : '';\n  if (\n    message.includes('Error: Uncaught') ||\n    message.includes('The above error occurred in') ||\n    message.includes('Consider adding an error boundary')\n  ) {\n    return; \u002F\u002F Suppress React's error boundary warnings in tests\n  }\n  originalConsoleError(...args);\n};\n```\n\n## Best Practices\n\n1. **Wrap every route-level component in an error boundary** -- Each page or route should have its own error boundary so that navigation to a broken page does not crash the entire application.\n\n2. **Use granular boundaries for independent widgets** -- Dashboard widgets, sidebar components, and data visualization panels should each have their own error boundary. A failing chart should not bring down the navigation.\n\n3. **Always provide a recovery action in fallback UIs** -- Every error fallback must include at least one actionable button: \"Try Again\", \"Reload Page\", or \"Go Home\". A dead-end error screen forces users to manually refresh.\n\n4. **Log errors with component stack traces** -- The `componentStack` from `getDerivedStateFromError` or `componentDidCatch` shows exactly where in the component tree the error occurred. Always include this in error reports.\n\n5. **Test error boundaries with multiple error types** -- Test with `TypeError`, `RangeError`, `SyntaxError`, network errors, and custom application errors. Different error types may need different fallback messaging.\n\n6. **Handle async errors explicitly** -- Since React error boundaries do not catch async errors by default, use the \"re-throw via state\" pattern: catch the async error, set it in state, and throw from render.\n\n7. **Implement retry with exponential backoff** -- When error boundaries support retry, implement exponential backoff to prevent rapid retry loops that overwhelm failing services.\n\n8. **Test error boundaries in production mode** -- Development mode shows additional error overlays and detailed stack traces. Production mode hides these. Test in production mode to verify users see the correct fallback.\n\n9. **Add error boundaries around dynamic imports** -- Every `React.lazy()` call should be wrapped in a `Suspense` with an error boundary. Chunk loading failures are common after deployments and must be handled gracefully.\n\n10. **Verify error boundaries do not swallow errors silently** -- An error boundary that catches an error but does not log it or show a fallback is worse than no boundary at all. Test that every caught error is both displayed and reported.\n\n11. **Test keyboard navigation within fallback UIs** -- Users who encounter an error boundary while navigating with a keyboard must be able to reach the retry button and other recovery actions without a mouse.\n\n12. **Reset error boundary state on route change** -- When a user navigates away from a page with an error and returns, the error boundary should reset and attempt to render the component again, not show the stale error state.\n\n## Anti-Patterns to Avoid\n\n1. **Catching errors without reporting them** -- An error boundary that renders a fallback but does not send the error to a monitoring service is a blind spot. Production errors caught by silent boundaries are invisible to the development team.\n\n2. **Using a single error boundary at the app root only** -- A single top-level boundary means any component failure replaces the entire UI with a fallback. This defeats the purpose of error containment. Use boundaries at multiple levels.\n\n3. **Showing raw error messages to users** -- Error messages like \"TypeError: Cannot read properties of undefined\" are meaningless to users and may expose implementation details. Always show user-friendly messages in production.\n\n4. **Retrying without clearing the error state** -- If a retry attempt does not properly reset the error boundary's internal state, it will continue showing the fallback even after the underlying issue is resolved.\n\n5. **Ignoring async error handling** -- Assuming that wrapping a component in an error boundary catches all errors within it, including those from `useEffect`, event handlers, and promises, is a dangerous misconception. These require explicit error handling.\n\n6. **Testing error boundaries only in development mode** -- React's development mode includes an error overlay that masks the actual error boundary behavior. Always run error boundary tests against a production build to verify real user experience.\n\n7. **Nesting too many boundaries** -- While granular boundaries are good, excessive nesting (every single component) creates maintenance burden and can make error UIs fragmented. Find the right balance at the feature or widget level.\n\n## Debugging Tips\n\n1. **Use React DevTools to inspect error boundary state** -- React DevTools shows the component tree including error boundary state. Look for boundaries in the \"errored\" state to understand which boundary caught which error.\n\n2. **Check the browser console for \"The above error occurred in...\" messages** -- React logs detailed component stack traces when an error boundary catches an error. These messages show the exact component path from the root to the error source.\n\n3. **Temporarily remove error boundaries to see raw errors** -- When debugging, temporarily remove the error boundary wrapping a problematic component. This lets you see the full unhandled error with its original stack trace.\n\n4. **Verify error boundary reset behavior with React key prop** -- Adding a `key` prop to an error boundary forces React to unmount and remount it when the key changes. Use this as a reset mechanism: `\u003CErrorBoundary key={resetKey}>`.\n\n5. **Test with React's Strict Mode enabled** -- Strict Mode double-renders components in development, which can expose error boundary issues related to side effects in render. Ensure boundaries work correctly under Strict Mode.\n\n6. **Watch for \"Maximum update depth exceeded\" in error recovery** -- If clicking \"Retry\" causes the component to immediately error again, it can create an infinite error-recovery loop. Add safeguards like retry counters or cooldown periods.\n\n7. **Check for hydration errors in SSR applications** -- Server-side rendered applications can trigger error boundaries during hydration when server-rendered HTML does not match client-rendered output. Test error boundaries specifically around the hydration phase.\n\n8. **Log the error boundary lifecycle** -- Add console logs to `getDerivedStateFromError` and `componentDidCatch` (or the equivalent hooks) to trace exactly when errors are caught, what fallback is rendered, and when recovery is attempted.\n\n9. **Verify that error boundaries handle errors during unmount** -- Components that throw errors during cleanup (in `useEffect` return functions or `componentWillUnmount`) may not be caught by error boundaries. Test these edge cases explicitly.\n\n10. **Use Sentry or similar tools to verify error boundary reports in staging** -- Before deploying to production, verify that error boundary reports actually reach your monitoring tool with correct source maps, component stacks, and user context.\n","# Error Boundary Tester Skill\n\nYou are an expert QA automation engineer specializing in error boundary and fault tolerance testing. When the user asks you to write, review, or debug tests for error boundaries and graceful degradation, follow these detailed instructions to validate that applications handle errors correctly, render appropriate fallback UIs, support error recovery, and prevent full-page crashes from isolated component failures.\n\n## Core Principles\n\n1. **Errors are inevitable, crashes are not** -- Every component will eventually encounter an error. Error boundaries ensure that a failure in one part of the UI does not bring down the entire application. Test that each error boundary contains failures within its scope.\n2. **Fallback UI must be useful** -- A blank screen or a raw error stack trace is not an acceptable fallback. Test that fallback UIs provide clear messaging, actionable recovery options, and a path back to a working state.\n3. **Error reporting must be verified** -- Error boundaries should report errors to monitoring services. Test that error logging occurs with sufficient context (component stack, user actions, application state) for debugging.\n4. **Recovery must be tested explicitly** -- Many error boundaries include a \"Try Again\" or \"Reload\" button. Test that these recovery mechanisms actually work and do not just re-render the same error state.\n5. **Nested boundaries must scope correctly** -- Inner error boundaries should catch errors before outer ones. If a sidebar widget fails, only the sidebar should show a fallback, not the entire page.\n6. **Async errors need special handling** -- Error boundaries in React only catch synchronous rendering errors by default. Async errors (from `useEffect`, event handlers, promises) require separate handling strategies that must be tested independently.\n\n## Project Structure\n\nOrganize error boundary test projects with this structure:\n\n```\ntests\u002F\n  error-boundaries\u002F\n    unit\u002F\n      error-boundary-component.test.tsx\n      fallback-ui.test.tsx\n      error-reporter.test.ts\n      recovery-flow.test.tsx\n    e2e\u002F\n      component-crash.spec.ts\n      nested-boundary.spec.ts\n      full-page-crash.spec.ts\n      chunk-load-failure.spec.ts\n      network-error.spec.ts\n    integration\u002F\n      error-logging.spec.ts\n      error-recovery.spec.ts\n  helpers\u002F\n    error-injector.ts\n    crash-component.tsx\n    boundary-test-utils.ts\n  fixtures\u002F\n    error-scenarios.fixture.ts\n  mocks\u002F\n    error-reporter.mock.ts\nplaywright.config.ts\nvitest.config.ts\n```\n\n## React Error Boundary Unit Testing\n\n### Testing the Error Boundary Component Itself\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Ferror-boundary-component.test.tsx\nimport { render, screen, fireEvent } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi, beforeEach } from 'vitest';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\n\n\u002F\u002F A component that throws on demand\nfunction CrashingComponent({ shouldCrash }: { shouldCrash: boolean }) {\n  if (shouldCrash) {\n    throw new Error('Intentional test crash');\n  }\n  return \u003Cdiv data-testid=\"healthy-content\">Everything is working\u003C\u002Fdiv>;\n}\n\n\u002F\u002F A component that throws during render\nfunction AlwaysCrashes(): JSX.Element {\n  throw new Error('Component always crashes');\n}\n\n\u002F\u002F A component that throws a specific error type\nfunction TypeErrorComponent(): JSX.Element {\n  const obj: Record\u003Cstring, unknown> = {};\n  \u002F\u002F Force a TypeError at runtime\n  return \u003Cdiv>{(obj as { nested: { value: string } }).nested.value}\u003C\u002Fdiv>;\n}\n\ndescribe('ErrorBoundary Component', () => {\n  let consoleErrorSpy: ReturnType\u003Ctypeof vi.spyOn>;\n\n  beforeEach(() => {\n    \u002F\u002F Suppress React's console.error for error boundaries in tests\n    consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});\n  });\n\n  test('renders children when no error occurs', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error occurred\u003C\u002Fdiv>}>\n        \u003CCrashingComponent shouldCrash={false} \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('healthy-content')).toBeInTheDocument();\n    expect(screen.queryByText('Error occurred')).not.toBeInTheDocument();\n  });\n\n  test('renders fallback UI when child component throws', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"fallback\">Something went wrong\u003C\u002Fdiv>}>\n        \u003CAlwaysCrashes \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('fallback')).toBeInTheDocument();\n    expect(screen.getByText('Something went wrong')).toBeInTheDocument();\n    expect(screen.queryByTestId('healthy-content')).not.toBeInTheDocument();\n  });\n\n  test('calls onError callback with error and component stack', () => {\n    const onError = vi.fn();\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv>Error\u003C\u002Fdiv>}\n        onError={onError}\n      >\n        \u003CAlwaysCrashes \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(onError).toHaveBeenCalledTimes(1);\n    expect(onError).toHaveBeenCalledWith(\n      expect.objectContaining({\n        message: 'Component always crashes',\n      }),\n      expect.objectContaining({\n        componentStack: expect.any(String),\n      })\n    );\n  });\n\n  test('catches TypeError from nested rendering', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"type-error-fallback\">Type error caught\u003C\u002Fdiv>}>\n        \u003CTypeErrorComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('type-error-fallback')).toBeInTheDocument();\n  });\n\n  test('different error boundaries catch errors independently', () => {\n    render(\n      \u003Cdiv>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"sidebar-fallback\">Sidebar error\u003C\u002Fdiv>}>\n          \u003CAlwaysCrashes \u002F>\n        \u003C\u002FErrorBoundary>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"main-fallback\">Main error\u003C\u002Fdiv>}>\n          \u003CCrashingComponent shouldCrash={false} \u002F>\n        \u003C\u002FErrorBoundary>\n      \u003C\u002Fdiv>\n    );\n\n    \u002F\u002F Sidebar should show fallback\n    expect(screen.getByTestId('sidebar-fallback')).toBeInTheDocument();\n    \u002F\u002F Main should show healthy content\n    expect(screen.getByTestId('healthy-content')).toBeInTheDocument();\n    \u002F\u002F Main fallback should NOT be shown\n    expect(screen.queryByTestId('main-fallback')).not.toBeInTheDocument();\n  });\n});\n```\n\n### Testing Fallback UI Content\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Ffallback-ui.test.tsx\nimport { render, screen } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi } from 'vitest';\nimport { ErrorFallback } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-fallback';\n\ndescribe('ErrorFallback Component', () => {\n  test('displays user-friendly error message', () => {\n    render(\n      \u003CErrorFallback\n        error={new Error('API request failed')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    \u002F\u002F Should show a friendly message, not the raw error\n    expect(screen.getByRole('heading')).toHaveTextContent(\u002Fsomething went wrong\u002Fi);\n    expect(screen.queryByText('API request failed')).not.toBeInTheDocument();\n  });\n\n  test('shows recovery button', () => {\n    const resetFn = vi.fn();\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={resetFn}\n      \u002F>\n    );\n\n    const retryButton = screen.getByRole('button', { name: \u002Ftry again\u002Fi });\n    expect(retryButton).toBeInTheDocument();\n  });\n\n  test('recovery button triggers resetErrorBoundary', async () => {\n    const resetFn = vi.fn();\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={resetFn}\n      \u002F>\n    );\n\n    const retryButton = screen.getByRole('button', { name: \u002Ftry again\u002Fi });\n    await retryButton.click();\n\n    expect(resetFn).toHaveBeenCalledTimes(1);\n  });\n\n  test('provides a link to navigate home as escape hatch', () => {\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    const homeLink = screen.getByRole('link', { name: \u002Fgo home|return home\u002Fi });\n    expect(homeLink).toHaveAttribute('href', '\u002F');\n  });\n\n  test('fallback UI is accessible', () => {\n    render(\n      \u003CErrorFallback\n        error={new Error('Test error')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    \u002F\u002F Should have proper ARIA attributes\n    const alertRegion = screen.getByRole('alert');\n    expect(alertRegion).toBeInTheDocument();\n\n    \u002F\u002F Retry button should be focusable\n    const retryButton = screen.getByRole('button', { name: \u002Ftry again\u002Fi });\n    expect(retryButton).not.toHaveAttribute('tabindex', '-1');\n  });\n\n  test('does not expose stack trace in production mode', () => {\n    const originalEnv = process.env.NODE_ENV;\n    process.env.NODE_ENV = 'production';\n\n    render(\n      \u003CErrorFallback\n        error={new Error('Sensitive error details here')}\n        resetErrorBoundary={vi.fn()}\n      \u002F>\n    );\n\n    expect(screen.queryByText(\u002FSensitive error details\u002F)).not.toBeInTheDocument();\n    expect(screen.queryByText(\u002Fat \u002F)).not.toBeInTheDocument(); \u002F\u002F No stack traces\n\n    process.env.NODE_ENV = originalEnv;\n  });\n});\n```\n\n## Error Injection for E2E Testing\n\n### Forced Error Injection via Playwright\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fcomponent-crash.spec.ts\nimport { test, expect, Page } from '@playwright\u002Ftest';\n\nasync function injectRenderError(page: Page, componentSelector: string): Promise\u003Cvoid> {\n  await page.evaluate((selector) => {\n    const element = document.querySelector(selector);\n    if (!element) throw new Error(`Element not found: ${selector}`);\n\n    \u002F\u002F Inject an error-throwing element that React will try to render\n    const errorDiv = document.createElement('div');\n    errorDiv.setAttribute('data-crash-injected', 'true');\n\n    \u002F\u002F Override innerHTML to force a React reconciliation error\n    Object.defineProperty(errorDiv, 'textContent', {\n      get() {\n        throw new Error('Injected render error for testing');\n      },\n    });\n\n    element.appendChild(errorDiv);\n  }, componentSelector);\n}\n\ntest.describe('Component Crash Recovery (E2E)', () => {\n  test('sidebar crash should not affect main content', async ({ page }) => {\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Verify both sidebar and main content are initially visible\n    await expect(page.locator('[data-testid=\"sidebar\"]')).toBeVisible();\n    await expect(page.locator('[data-testid=\"main-content\"]')).toBeVisible();\n\n    \u002F\u002F Simulate a JavaScript error in the sidebar component\n    await page.evaluate(() => {\n      \u002F\u002F Dispatch a custom event that triggers an error in the sidebar\n      window.dispatchEvent(\n        new CustomEvent('__test_inject_error', {\n          detail: { component: 'sidebar' },\n        })\n      );\n    });\n\n    \u002F\u002F Main content should still be functional\n    await expect(page.locator('[data-testid=\"main-content\"]')).toBeVisible();\n\n    \u002F\u002F Sidebar should show error fallback\n    const sidebarFallback = page.locator('[data-testid=\"sidebar-error-fallback\"]');\n    await expect(sidebarFallback).toBeVisible();\n\n    \u002F\u002F Sidebar fallback should have a retry option\n    const retryButton = sidebarFallback.locator('button:has-text(\"Retry\")');\n    await expect(retryButton).toBeVisible();\n  });\n\n  test('clicking retry should recover from error', async ({ page }) => {\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Trigger a recoverable error\n    await page.evaluate(() => {\n      window.dispatchEvent(\n        new CustomEvent('__test_inject_error', {\n          detail: { component: 'widget', recoverable: true },\n        })\n      );\n    });\n\n    \u002F\u002F Verify fallback is shown\n    const fallback = page.locator('[data-testid=\"widget-error-fallback\"]');\n    await expect(fallback).toBeVisible();\n\n    \u002F\u002F Click retry\n    await fallback.locator('button:has-text(\"Try Again\")').click();\n\n    \u002F\u002F Verify the component recovered\n    await expect(page.locator('[data-testid=\"widget-content\"]')).toBeVisible();\n    await expect(fallback).not.toBeVisible();\n  });\n});\n```\n\n### Testing Error Boundaries with Network Failures\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fnetwork-error.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Network Error Boundaries', () => {\n  test('should show error boundary when API request fails', async ({ page }) => {\n    \u002F\u002F Intercept API calls and force them to fail\n    await page.route('**\u002Fapi\u002Fdashboard\u002Fstats', (route) => {\n      route.abort('connectionrefused');\n    });\n\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F The stats component should show its error boundary\n    const statsError = page.locator('[data-testid=\"stats-error\"]');\n    await expect(statsError).toBeVisible();\n    await expect(statsError).toContainText(\u002Funable to load|failed to load\u002Fi);\n\n    \u002F\u002F Other dashboard components should still work\n    await expect(page.locator('[data-testid=\"recent-activity\"]')).toBeVisible();\n  });\n\n  test('should recover when API becomes available again', async ({ page }) => {\n    let requestCount = 0;\n\n    \u002F\u002F Fail the first request, succeed on retry\n    await page.route('**\u002Fapi\u002Fdashboard\u002Fstats', (route) => {\n      requestCount++;\n      if (requestCount \u003C= 1) {\n        route.abort('connectionrefused');\n      } else {\n        route.fulfill({\n          status: 200,\n          contentType: 'application\u002Fjson',\n          body: JSON.stringify({ total: 42, active: 10 }),\n        });\n      }\n    });\n\n    await page.goto('\u002Fdashboard');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Error should be showing\n    const statsError = page.locator('[data-testid=\"stats-error\"]');\n    await expect(statsError).toBeVisible();\n\n    \u002F\u002F Click retry\n    await statsError.locator('button:has-text(\"Retry\")').click();\n\n    \u002F\u002F Stats should now display correctly\n    await expect(page.locator('[data-testid=\"stats-content\"]')).toBeVisible();\n    await expect(page.locator('[data-testid=\"stats-total\"]')).toContainText('42');\n  });\n\n  test('should handle 500 server errors gracefully', async ({ page }) => {\n    await page.route('**\u002Fapi\u002Fposts', (route) => {\n      route.fulfill({\n        status: 500,\n        contentType: 'application\u002Fjson',\n        body: JSON.stringify({ error: 'Internal Server Error' }),\n      });\n    });\n\n    await page.goto('\u002Fposts');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Should show a user-friendly error, not a raw 500 message\n    await expect(page.locator('[role=\"alert\"]')).toBeVisible();\n    await expect(page.locator('[role=\"alert\"]')).not.toContainText('500');\n    await expect(page.locator('[role=\"alert\"]')).not.toContainText('Internal Server Error');\n  });\n});\n```\n\n## Nested Error Boundary Scoping\n\nTesting that inner boundaries catch errors before outer boundaries is critical for maintaining partial functionality during failures.\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Fnested-boundary.test.tsx\nimport { render, screen } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi } from 'vitest';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\n\nfunction CrashingWidget(): JSX.Element {\n  throw new Error('Widget crashed');\n}\n\nfunction HealthyWidget(): JSX.Element {\n  return \u003Cdiv data-testid=\"healthy-widget\">Working widget\u003C\u002Fdiv>;\n}\n\ndescribe('Nested Error Boundary Scoping', () => {\n  const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});\n\n  test('inner boundary catches error before outer boundary', () => {\n    const innerOnError = vi.fn();\n    const outerOnError = vi.fn();\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv data-testid=\"outer-fallback\">Outer error\u003C\u002Fdiv>}\n        onError={outerOnError}\n      >\n        \u003Cdiv data-testid=\"page-layout\">\n          \u003CErrorBoundary\n            fallback={\u003Cdiv data-testid=\"inner-fallback\">Inner error\u003C\u002Fdiv>}\n            onError={innerOnError}\n          >\n            \u003CCrashingWidget \u002F>\n          \u003C\u002FErrorBoundary>\n          \u003CHealthyWidget \u002F>\n        \u003C\u002Fdiv>\n      \u003C\u002FErrorBoundary>\n    );\n\n    \u002F\u002F Inner fallback should be shown\n    expect(screen.getByTestId('inner-fallback')).toBeInTheDocument();\n    \u002F\u002F Healthy widget should still be visible\n    expect(screen.getByTestId('healthy-widget')).toBeInTheDocument();\n    \u002F\u002F Outer fallback should NOT be shown\n    expect(screen.queryByTestId('outer-fallback')).not.toBeInTheDocument();\n    \u002F\u002F Page layout should still be intact\n    expect(screen.getByTestId('page-layout')).toBeInTheDocument();\n\n    \u002F\u002F Inner onError should be called, outer should NOT\n    expect(innerOnError).toHaveBeenCalledTimes(1);\n    expect(outerOnError).not.toHaveBeenCalled();\n  });\n\n  test('outer boundary catches when there is no inner boundary', () => {\n    const outerOnError = vi.fn();\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv data-testid=\"outer-fallback\">Page error\u003C\u002Fdiv>}\n        onError={outerOnError}\n      >\n        \u003CCrashingWidget \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(screen.getByTestId('outer-fallback')).toBeInTheDocument();\n    expect(outerOnError).toHaveBeenCalledTimes(1);\n  });\n\n  test('multiple sibling boundaries are independent', () => {\n    render(\n      \u003Cdiv>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"boundary-a-fallback\">A failed\u003C\u002Fdiv>}>\n          \u003CCrashingWidget \u002F>\n        \u003C\u002FErrorBoundary>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"boundary-b-fallback\">B failed\u003C\u002Fdiv>}>\n          \u003CHealthyWidget \u002F>\n        \u003C\u002FErrorBoundary>\n        \u003CErrorBoundary fallback={\u003Cdiv data-testid=\"boundary-c-fallback\">C failed\u003C\u002Fdiv>}>\n          \u003CCrashingWidget \u002F>\n        \u003C\u002FErrorBoundary>\n      \u003C\u002Fdiv>\n    );\n\n    \u002F\u002F A and C should show fallbacks\n    expect(screen.getByTestId('boundary-a-fallback')).toBeInTheDocument();\n    expect(screen.getByTestId('boundary-c-fallback')).toBeInTheDocument();\n    \u002F\u002F B should show healthy content\n    expect(screen.getByTestId('healthy-widget')).toBeInTheDocument();\n    expect(screen.queryByTestId('boundary-b-fallback')).not.toBeInTheDocument();\n  });\n});\n```\n\n## Error Logging and Reporting Verification\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Ferror-reporter.test.ts\nimport { describe, test, expect, vi, beforeEach } from 'vitest';\nimport { render } from '@testing-library\u002Freact';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\nimport * as errorReporter from '..\u002F..\u002Fsrc\u002Flib\u002Ferror-reporter';\n\nfunction CrashingComponent(): JSX.Element {\n  throw new Error('Crash for reporting test');\n}\n\ndescribe('Error Reporting from Boundaries', () => {\n  let reportSpy: ReturnType\u003Ctypeof vi.spyOn>;\n\n  beforeEach(() => {\n    reportSpy = vi.spyOn(errorReporter, 'reportError').mockResolvedValue(undefined);\n    vi.spyOn(console, 'error').mockImplementation(() => {});\n  });\n\n  test('error boundary should report error to monitoring service', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error\u003C\u002Fdiv>}>\n        \u003CCrashingComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    expect(reportSpy).toHaveBeenCalledTimes(1);\n    expect(reportSpy).toHaveBeenCalledWith(\n      expect.objectContaining({\n        message: 'Crash for reporting test',\n      }),\n      expect.objectContaining({\n        componentStack: expect.any(String),\n      })\n    );\n  });\n\n  test('error report should include component stack trace', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error\u003C\u002Fdiv>}>\n        \u003Cdiv>\n          \u003Csection>\n            \u003CCrashingComponent \u002F>\n          \u003C\u002Fsection>\n        \u003C\u002Fdiv>\n      \u003C\u002FErrorBoundary>\n    );\n\n    const [, errorInfo] = reportSpy.mock.calls[0];\n    expect(errorInfo.componentStack).toContain('CrashingComponent');\n  });\n\n  test('error report should not include PII', () => {\n    render(\n      \u003CErrorBoundary fallback={\u003Cdiv>Error\u003C\u002Fdiv>}>\n        \u003CCrashingComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    const [error, errorInfo] = reportSpy.mock.calls[0];\n    const reportString = JSON.stringify({ error: error.message, ...errorInfo });\n\n    \u002F\u002F Ensure no emails, tokens, or other PII in the report\n    expect(reportString).not.toMatch(\u002F@.*\\.\u002F);\n    expect(reportString).not.toMatch(\u002FBearer\\s+\u002F);\n    expect(reportString).not.toMatch(\u002Fpassword\u002Fi);\n  });\n});\n```\n\n## Async Error Handling\n\nReact error boundaries do not catch errors in event handlers, async functions, or `setTimeout` callbacks. These require separate handling.\n\n```typescript\n\u002F\u002F tests\u002Funit\u002Fasync-error-handling.test.tsx\nimport { render, screen, fireEvent, waitFor } from '@testing-library\u002Freact';\nimport { describe, test, expect, vi } from 'vitest';\nimport { useState } from 'react';\nimport { ErrorBoundary } from '..\u002F..\u002Fsrc\u002Fcomponents\u002Ferror-boundary';\n\nfunction AsyncCrashingComponent() {\n  const [error, setError] = useState\u003CError | null>(null);\n\n  const handleClick = async () => {\n    try {\n      const response = await fetch('\u002Fapi\u002Fdata');\n      if (!response.ok) throw new Error('API failed');\n      const data = await response.json();\n      return data;\n    } catch (err) {\n      setError(err as Error);\n    }\n  };\n\n  if (error) {\n    throw error; \u002F\u002F Re-throw to be caught by error boundary\n  }\n\n  return (\n    \u003Cbutton data-testid=\"trigger\" onClick={handleClick}>\n      Load Data\n    \u003C\u002Fbutton>\n  );\n}\n\ndescribe('Async Error Handling', () => {\n  vi.spyOn(console, 'error').mockImplementation(() => {});\n\n  test('async errors should be caught by error boundary when re-thrown via state', async () => {\n    \u002F\u002F Mock the fetch to fail\n    global.fetch = vi.fn().mockRejectedValue(new Error('Network error'));\n\n    render(\n      \u003CErrorBoundary\n        fallback={\u003Cdiv data-testid=\"async-fallback\">Async error caught\u003C\u002Fdiv>}\n      >\n        \u003CAsyncCrashingComponent \u002F>\n      \u003C\u002FErrorBoundary>\n    );\n\n    \u002F\u002F Trigger the async operation\n    fireEvent.click(screen.getByTestId('trigger'));\n\n    \u002F\u002F Wait for the error boundary to render the fallback\n    await waitFor(() => {\n      expect(screen.getByTestId('async-fallback')).toBeInTheDocument();\n    });\n  });\n});\n```\n\n## Chunk Loading Failure Handling\n\nDynamic imports can fail when deployment invalidates old chunks. This is a common production error that error boundaries must handle.\n\n```typescript\n\u002F\u002F tests\u002Fe2e\u002Fchunk-load-failure.spec.ts\nimport { test, expect } from '@playwright\u002Ftest';\n\ntest.describe('Chunk Loading Failure', () => {\n  test('should show error boundary when a lazy-loaded chunk fails', async ({ page }) => {\n    \u002F\u002F Intercept chunk requests and make them fail\n    await page.route('**\u002F*.chunk.js', (route) => {\n      route.fulfill({\n        status: 404,\n        body: 'Not Found',\n      });\n    });\n\n    await page.goto('\u002F');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Navigate to a route that uses lazy loading\n    await page.click('a[href=\"\u002Fsettings\"]');\n\n    \u002F\u002F Should show a meaningful error, not a blank page\n    await expect(\n      page.locator('[role=\"alert\"], [data-testid=\"chunk-error\"]')\n    ).toBeVisible({ timeout: 10000 });\n\n    \u002F\u002F Should offer a way to recover (typically a page reload)\n    const reloadButton = page.locator(\n      'button:has-text(\"Reload\"), button:has-text(\"Refresh\")'\n    );\n    await expect(reloadButton).toBeVisible();\n  });\n\n  test('should auto-retry chunk loading before showing error', async ({ page }) => {\n    let chunkRequestCount = 0;\n\n    await page.route('**\u002Fsettings.chunk.js', (route) => {\n      chunkRequestCount++;\n      if (chunkRequestCount \u003C= 2) {\n        \u002F\u002F Fail first 2 attempts\n        route.fulfill({ status: 500, body: 'Server Error' });\n      } else {\n        \u002F\u002F Succeed on third attempt\n        route.continue();\n      }\n    });\n\n    await page.goto('\u002F');\n    await page.click('a[href=\"\u002Fsettings\"]');\n\n    \u002F\u002F The page should eventually load after retries\n    await expect(\n      page.locator('[data-testid=\"settings-page\"]')\n    ).toBeVisible({ timeout: 15000 });\n\n    \u002F\u002F Should have retried at least once\n    expect(chunkRequestCount).toBeGreaterThan(1);\n  });\n\n  test('stale deployment chunk failure should suggest page refresh', async ({ page }) => {\n    \u002F\u002F Simulate a deployment scenario where chunk hashes have changed\n    await page.route('**\u002F*.[a-f0-9]*.js', (route) => {\n      if (route.request().url().includes('old-hash')) {\n        route.fulfill({ status: 404, body: 'Not Found' });\n      } else {\n        route.continue();\n      }\n    });\n\n    await page.goto('\u002F');\n    await page.waitForLoadState('networkidle');\n\n    \u002F\u002F Check that the error message mentions updating or refreshing\n    const errorMessage = page.locator('[role=\"alert\"]');\n    if (await errorMessage.isVisible()) {\n      const text = await errorMessage.textContent();\n      expect(text).toMatch(\u002Frefresh|reload|update|new version\u002Fi);\n    }\n  });\n});\n```\n\n## Configuration\n\n### Vitest Configuration for Error Boundary Tests\n\n```typescript\n\u002F\u002F vitest.config.ts\nimport { defineConfig } from 'vitest\u002Fconfig';\nimport react from '@vitejs\u002Fplugin-react';\n\nexport default defineConfig({\n  plugins: [react()],\n  test: {\n    environment: 'jsdom',\n    setupFiles: ['.\u002Ftests\u002Fsetup.ts'],\n    globals: true,\n    include: [\n      'tests\u002Ferror-boundaries\u002Funit\u002F**\u002F*.test.{ts,tsx}',\n      'tests\u002Ferror-boundaries\u002Fintegration\u002F**\u002F*.test.{ts,tsx}',\n    ],\n    coverage: {\n      include: [\n        'src\u002Fcomponents\u002Ferror-boundary\u002F**',\n        'src\u002Fcomponents\u002Ferror-fallback\u002F**',\n        'src\u002Flib\u002Ferror-reporter.*',\n      ],\n      thresholds: {\n        statements: 90,\n        branches: 85,\n        functions: 90,\n        lines: 90,\n      },\n    },\n  },\n});\n```\n\n### Playwright Configuration for Error Boundary E2E Tests\n\n```typescript\n\u002F\u002F playwright.config.ts\nimport { defineConfig, devices } from '@playwright\u002Ftest';\n\nexport default defineConfig({\n  testDir: '.\u002Ftests\u002Ferror-boundaries\u002Fe2e',\n  fullyParallel: true,\n  retries: 1,\n  reporter: [\n    ['html', { open: 'never' }],\n    ['json', { outputFile: 'error-boundary-results.json' }],\n  ],\n  use: {\n    baseURL: process.env.BASE_URL || 'http:\u002F\u002Flocalhost:3000',\n    trace: 'on-first-retry',\n    screenshot: 'only-on-failure',\n    video: 'on-first-retry',\n  },\n  projects: [\n    {\n      name: 'error-boundaries-chrome',\n      use: { ...devices['Desktop Chrome'] },\n    },\n    {\n      name: 'error-boundaries-firefox',\n      use: { ...devices['Desktop Firefox'] },\n    },\n    {\n      name: 'error-boundaries-mobile',\n      use: { ...devices['iPhone 14'] },\n    },\n  ],\n});\n```\n\n### Test Setup File\n\n```typescript\n\u002F\u002F tests\u002Fsetup.ts\nimport '@testing-library\u002Fjest-dom';\nimport { cleanup } from '@testing-library\u002Freact';\nimport { afterEach, vi } from 'vitest';\n\nafterEach(() => {\n  cleanup();\n  vi.restoreAllMocks();\n});\n\n\u002F\u002F Suppress React error boundary console.error in test output\n\u002F\u002F while still allowing test assertions on error reporting\nconst originalConsoleError = console.error;\nconsole.error = (...args: unknown[]) => {\n  const message = typeof args[0] === 'string' ? args[0] : '';\n  if (\n    message.includes('Error: Uncaught') ||\n    message.includes('The above error occurred in') ||\n    message.includes('Consider adding an error boundary')\n  ) {\n    return; \u002F\u002F Suppress React's error boundary warnings in tests\n  }\n  originalConsoleError(...args);\n};\n```\n\n## Best Practices\n\n1. **Wrap every route-level component in an error boundary** -- Each page or route should have its own error boundary so that navigation to a broken page does not crash the entire application.\n\n2. **Use granular boundaries for independent widgets** -- Dashboard widgets, sidebar components, and data visualization panels should each have their own error boundary. A failing chart should not bring down the navigation.\n\n3. **Always provide a recovery action in fallback UIs** -- Every error fallback must include at least one actionable button: \"Try Again\", \"Reload Page\", or \"Go Home\". A dead-end error screen forces users to manually refresh.\n\n4. **Log errors with component stack traces** -- The `componentStack` from `getDerivedStateFromError` or `componentDidCatch` shows exactly where in the component tree the error occurred. Always include this in error reports.\n\n5. **Test error boundaries with multiple error types** -- Test with `TypeError`, `RangeError`, `SyntaxError`, network errors, and custom application errors. Different error types may need different fallback messaging.\n\n6. **Handle async errors explicitly** -- Since React error boundaries do not catch async errors by default, use the \"re-throw via state\" pattern: catch the async error, set it in state, and throw from render.\n\n7. **Implement retry with exponential backoff** -- When error boundaries support retry, implement exponential backoff to prevent rapid retry loops that overwhelm failing services.\n\n8. **Test error boundaries in production mode** -- Development mode shows additional error overlays and detailed stack traces. Production mode hides these. Test in production mode to verify users see the correct fallback.\n\n9. **Add error boundaries around dynamic imports** -- Every `React.lazy()` call should be wrapped in a `Suspense` with an error boundary. Chunk loading failures are common after deployments and must be handled gracefully.\n\n10. **Verify error boundaries do not swallow errors silently** -- An error boundary that catches an error but does not log it or show a fallback is worse than no boundary at all. Test that every caught error is both displayed and reported.\n\n11. **Test keyboard navigation within fallback UIs** -- Users who encounter an error boundary while navigating with a keyboard must be able to reach the retry button and other recovery actions without a mouse.\n\n12. **Reset error boundary state on route change** -- When a user navigates away from a page with an error and returns, the error boundary should reset and attempt to render the component again, not show the stale error state.\n\n## Anti-Patterns to Avoid\n\n1. **Catching errors without reporting them** -- An error boundary that renders a fallback but does not send the error to a monitoring service is a blind spot. Production errors caught by silent boundaries are invisible to the development team.\n\n2. **Using a single error boundary at the app root only** -- A single top-level boundary means any component failure replaces the entire UI with a fallback. This defeats the purpose of error containment. Use boundaries at multiple levels.\n\n3. **Showing raw error messages to users** -- Error messages like \"TypeError: Cannot read properties of undefined\" are meaningless to users and may expose implementation details. Always show user-friendly messages in production.\n\n4. **Retrying without clearing the error state** -- If a retry attempt does not properly reset the error boundary's internal state, it will continue showing the fallback even after the underlying issue is resolved.\n\n5. **Ignoring async error handling** -- Assuming that wrapping a component in an error boundary catches all errors within it, including those from `useEffect`, event handlers, and promises, is a dangerous misconception. These require explicit error handling.\n\n6. **Testing error boundaries only in development mode** -- React's development mode includes an error overlay that masks the actual error boundary behavior. Always run error boundary tests against a production build to verify real user experience.\n\n7. **Nesting too many boundaries** -- While granular boundaries are good, excessive nesting (every single component) creates maintenance burden and can make error UIs fragmented. Find the right balance at the feature or widget level.\n\n## Debugging Tips\n\n1. **Use React DevTools to inspect error boundary state** -- React DevTools shows the component tree including error boundary state. Look for boundaries in the \"errored\" state to understand which boundary caught which error.\n\n2. **Check the browser console for \"The above error occurred in...\" messages** -- React logs detailed component stack traces when an error boundary catches an error. These messages show the exact component path from the root to the error source.\n\n3. **Temporarily remove error boundaries to see raw errors** -- When debugging, temporarily remove the error boundary wrapping a problematic component. This lets you see the full unhandled error with its original stack trace.\n\n4. **Verify error boundary reset behavior with React key prop** -- Adding a `key` prop to an error boundary forces React to unmount and remount it when the key changes. Use this as a reset mechanism: `\u003CErrorBoundary key={resetKey}>`.\n\n5. **Test with React's Strict Mode enabled** -- Strict Mode double-renders components in development, which can expose error boundary issues related to side effects in render. Ensure boundaries work correctly under Strict Mode.\n\n6. **Watch for \"Maximum update depth exceeded\" in error recovery** -- If clicking \"Retry\" causes the component to immediately error again, it can create an infinite error-recovery loop. Add safeguards like retry counters or cooldown periods.\n\n7. **Check for hydration errors in SSR applications** -- Server-side rendered applications can trigger error boundaries during hydration when server-rendered HTML does not match client-rendered output. Test error boundaries specifically around the hydration phase.\n\n8. **Log the error boundary lifecycle** -- Add console logs to `getDerivedStateFromError` and `componentDidCatch` (or the equivalent hooks) to trace exactly when errors are caught, what fallback is rendered, and when recovery is attempted.\n\n9. **Verify that error boundaries handle errors during unmount** -- Components that throw errors during cleanup (in `useEffect` return functions or `componentWillUnmount`) may not be caught by error boundaries. Test these edge cases explicitly.\n\n10. **Use Sentry or similar tools to verify error boundary reports in staging** -- Before deploying to production, verify that error boundary reports actually reach your monitoring tool with correct source maps, component stacks, and user context.\n",{"name":5,"tags":24,"agents":32,"author":45,"domains":46,"license":15,"version":48,"languages":49,"frameworks":52,"description":7,"testingTypes":56},[25,26,27,28,29,30,31],"error-boundary","error-handling","graceful-degradation","fallback-ui","react-error-boundary","crash-recovery","resilience",[33,34,35,36,37,38,39,40,41,42,43,44],"claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","gemini-cli","amp","Pramod",[47],"web","1.0.0",[50,51],"typescript","javascript",[53,54,55],"playwright","jest","vitest",[57,58],"e2e","unit","main","eac438ea9216a7cb8a570cab803eb01eeafc6793","skills\u002Fqa\u002Ferror-boundary-tester","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m","https:\u002F\u002Fid-preview--d5bef06d-6c9e-4563-a3d4-a855b9d61610.lovable.app\u002F","Eu sou Antonio B. B. Ndombe \r\nEu sou um Pesquisador e desenvolvedor de sistema autonomia cognitivos, fundador de sistemas ODCs ( organismos digital conscientes)","2026-11-04 06:53:39",{"source":8,"skillName":5,"commands":68,"prompt":78,"zipAvailable":79},[69,72,75],{"tool":70,"command":71},"npx","npx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Error Boundary Tester\"",{"tool":73,"command":74},"bunx","bunx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Error Boundary Tester\"",{"tool":76,"command":77},"pnpm","pnpm dlx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Error Boundary Tester\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Ferror-boundary-tester\u002FSKILL.md",true,[],[82,90,97,104,111,118],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7DASC6FSCJP49JZBSK0NY1Z","nemoclaw-user-reference","Describes the NemoClaw integration layer and blueprint architecture and how they orchestrate compatible agent sandboxes. Use when looking up architecture, agent integration, plugin structure, or blueprint design. Trigger keywords - nemoclaw architecture, nemoclaw agent architecture, nemoclaw plugin blueprint structure, nemoclaw vs openshell, which cli, nemoclaw cli, openshell cli, sandbox commands, nemoclaw cli commands, nemoclaw command reference, nemoclaw network policy, sandbox egress control operator approval, nemoclaw troubleshooting, nemoclaw debug sandbox issues.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-reference\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7DAS5S79VK33XFGVAM2TFWF","nemoclaw-user-overview","Explains how OpenClaw, OpenShell, and NemoClaw form the ecosystem, NemoClaw's position in the stack, what NemoClaw adds beyond the community sandbox, and when to prefer NemoClaw versus integrating OpenShell and OpenClaw directly. Use when users ask about the relationship between OpenClaw, OpenShell, and NemoClaw, or when to use NemoClaw versus OpenShell. Trigger keywords - nemoclaw ecosystem, openclaw openshell, nemoclaw vs openshell, sandboxed openclaw, how nemoclaw works, nemoclaw sandbox lifecycle blueprint, nemoclaw overview, openclaw always-on assistants, nvidia openshell, nvidia nemotron, nemoclaw release notes, nemoclaw changelog.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-overview\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M7DAS0PQEMET5MNGZ1ABSZVS","nemoclaw-user-monitor-sandbox","Inspects sandbox health, traces agent behavior, and diagnoses problems. Use when monitoring a running sandbox, debugging agent issues, or checking sandbox logs. Trigger keywords - monitor nemoclaw sandbox, debug nemoclaw agent issues.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-monitor-sandbox\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":19},"01M7DARQYGF7E9A69VH6S3CGN9","nemoclaw-user-manage-sandboxes","Explains operational tasks after the quickstart: listing sandboxes, status and health checks, logs, diagnostics, port forwards, multiple sandboxes, credential reset, rebuilds, network presets, upgrades, and uninstall. Trigger keywords - manage nemoclaw sandboxes, nemoclaw status, nemoclaw list, nemoclaw dashboard port, nemoclaw rebuild, nemoclaw upgrade sandboxes, nemoclaw uninstall, sandbox mutability, sandbox runtime configuration, sandbox rebuild, nemoclaw backup, nemoclaw restore, workspace backup, openshell sandbox download upload, nemoclaw messaging channels, nemoclaw telegram, nemoclaw discord, nemoclaw slack, nemoclaw wechat, nemoclaw whatsapp, openshell channel messaging, nemoclaw workspace files, soul.md, user.md, identity.md, agents.md, sandbox persistence.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-sandboxes\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":19},"01M7DARH8BRTG51TRCAB7YWDJ4","nemoclaw-user-manage-policy","Adds, removes, or modifies allowed endpoints in the sandbox policy. Use when customizing network policy, changing egress rules, or configuring sandbox endpoint access. Trigger keywords - customize nemoclaw network policy, sandbox egress policy configuration, nemoclaw integration policy examples, post-install policy setup, openshell approval workflow, policy preset, nemoclaw approve network requests, sandbox egress approval tui.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-policy\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":86,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":19},"01M7DARAT62M2VR37590VCZ5NS","nemoclaw-user-get-started","Installs NemoClaw, launches a sandbox, and runs the first agent prompt. Use when onboarding, installing, or launching a NemoClaw sandbox for the first time. Trigger keywords - nemoclaw quickstart, install nemoclaw openclaw sandbox, nemohermes quickstart, hermes agent nemoclaw, run hermes openshell sandbox, nemoclaw prerequisites, nemoclaw supported platforms, nemoclaw hardware software, nemoclaw windows wsl2 setup, nemoclaw install windows docker desktop.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-get-started\u002FSKILL.md",[],[]]