Error Boundary Tester
БесплатноБез исполняемых скриптовНе проверенValidate error boundary implementations in React and other frameworks ensuring graceful degradation, proper fallback UI rendering, and error recovery flows
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Error Boundary Tester Skill
You 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.
Core Principles
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Project Structure
Organize error boundary test projects with this structure:
tests/
error-boundaries/
unit/
error-boundary-component.test.tsx
fallback-ui.test.tsx
error-reporter.test.ts
recovery-flow.test.tsx
e2e/
component-crash.spec.ts
nested-boundary.spec.ts
full-page-crash.spec.ts
chunk-load-failure.spec.ts
network-error.spec.ts
integration/
error-logging.spec.ts
error-recovery.spec.ts
helpers/
error-injector.ts
crash-component.tsx
boundary-test-utils.ts
fixtures/
error-scenarios.fixture.ts
mocks/
error-reporter.mock.ts
playwright.config.ts
vitest.config.ts
React Error Boundary Unit Testing
Testing the Error Boundary Component Itself
// tests/unit/error-boundary-component.test.tsx
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, test, expect, vi, beforeEach } from 'vitest';
import { ErrorBoundary } from '../../src/components/error-boundary';
// A component that throws on demand
function CrashingComponent({ shouldCrash }: { shouldCrash: boolean }) {
if (shouldCrash) {
throw new Error('Intentional test crash');
}
return <div data-testid="healthy-content">Everything is working</div>;
}
// A component that throws during render
function AlwaysCrashes(): JSX.Element {
throw new Error('Component always crashes');
}
// A component that throws a specific error type
function TypeErrorComponent(): JSX.Element {
const obj: Record<string, unknown> = {};
// Force a TypeError at runtime
return <div>{(obj as { nested: { value: string } }).nested.value}</div>;
}
describe('ErrorBoundary Component', () => {
let consoleErrorSpy: ReturnType<typeof vi.spyOn>;
beforeEach(() => {
// Suppress React's console.error for error boundaries in tests
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
});
test('renders children when no error occurs', () => {
render(
<ErrorBoundary fallback={<div>Error occurred</div>}>
<CrashingComponent shouldCrash={false} />
</ErrorBoundary>
);
expect(screen.getByTestId('healthy-content')).toBeInTheDocument();
expect(screen.queryByText('Error occurred')).not.toBeInTheDocument();
});
test('renders fallback UI when child component throws', () => {
render(
<ErrorBoundary fallback={<div data-testid="fallback">Something went wrong</div>}>
<AlwaysCrashes />
</ErrorBoundary>
);
expect(screen.getByTestId('fallback')).toBeInTheDocument();
expect(screen.getByText('Something went wrong')).toBeInTheDocument();
expect(screen.queryByTestId('healthy-content')).not.toBeInTheDocument();
});
test('calls onError callback with error and component stack', () => {
const onError = vi.fn();
render(
<ErrorBoundary
fallback={<div>Error</div>}
onError={onError}
>
<AlwaysCrashes />
</ErrorBoundary>
);
expect(onError).toHaveBeenCalledTimes(1);
expect(onError).toHaveBeenCalledWith(
expect.objectContaining({
message
Установить Error Boundary Tester в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Error Boundary Tester?
Validate error boundary implementations in React and other frameworks ensuring graceful degradation, proper fallback UI rendering, and error recovery flows
Как установить скилл Error Boundary Tester?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Error Boundary Tester запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic