Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Error Boundary Tester

БесплатноБез исполняемых скриптовНе проверен

Validate error boundary implementations in React and other frameworks ensuring graceful degradation, proper fallback UI rendering, and error recovery flows

PramodDuttaот 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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
Полный SKILL.md на GitHub

Установить 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), без исполняемых скриптов.

Похожие скиллы

Сравнить Error Boundary Tester с