Command Palette

Search for a command to run...

Назад к скиллам
скилл № 17614

frontend-testing

Use when the user asks about frontend testing, component tests with Testing Library, Vitest or Jest, userEvent, mocking APIs with MSW, Playwright or Cypress…

БесплатноБез исполняемых скриптов
j4flmaoот j4flmao★ 47 звёзд на GitHub

Установить frontend-testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Frontend Testing

Purpose

Test user behavior, not implementation. Query elements the way users find them (by role, label, text). UserEvent simulates real interactions. Every component has an accessibility check.

Agent Protocol

Trigger

Exact user phrases: "frontend testing", "component test", "React testing", "Vue testing", "Angular testing", "testing library", "Cypress", "Playwright", "snapshot test", "what to test frontend".

Input Context

Before activating, verify:

  • The framework is known (React, Vue, Angular).
  • The testing library is known (Testing Library, Playwright, Cypress) or can be inferred.
  • The component or page being tested is specified.

Output Artifact

No file output. Produces test code as text.

Response Format

Test file:

describe('{Component}', () => {
  it('should {expected behavior} when {condition}', () => {
    // render
    // interact
    // assert
  })
})

No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.

Completion Criteria

  • Queries use getByRole, getByLabelText, or getByText (never getByTestId unless unavoidable).
  • userEvent used instead of fireEvent.
  • Each test has exactly one behavior assertion.
  • Component tests cover: happy path, error state, empty state, loading state.
  • E2E tests cover only critical user journeys (<10 per app).
  • Accessibility assertion in every component test (axe-core).
  • No snapshot tests.

Max Response Length

Per test: 20 lines.

Testing Architecture / Decision Trees

Test Type Decision Tree

What are you testing?
  |-- Single component logic -->
  |     UNIT / COMPONENT TEST
  |     Tool: Vitest / Jest + Testing Library
  |     Coverage: happy path, empty, loading, error, edge cases
  |     Assert: rendered output, called handlers, accessibility
  |
  |-- Multi-component interaction -->
  |     INTEGRATION TEST
  |     Tool: Vitest / Jest + Testing Library
  |     Approach: render parent, mock child API calls with MSW
  |     Assert: data flows correctly between components
  |
  |-- Full user journey -->
  |     E2E TEST
  |     Tool: Playwright / Cypress
  |     Coverage: 5-10 critical journeys per app (login, purchase, search)
  |     Assert: navigation, data persistence, UI flow
  |
  |-- Visual appearance -->
        VISUAL REGRESSION TEST
        Tool: Chromatic / Percy / Playwright snapshot
        Coverage: changed components only (diff-based)
        Assert: pixel-perfect match with baseline

Query Priority Decision Tree

How does the user find the element?
  |-- By role + accessible name (button "Submit", link "View details") -->
  |     getByRole('button', { name: /submit/i })
  |     Preferred. Matches accessibility tree.
  |
  |-- By associated label (form fields) -->
  |     getByLabelText(/email/i)
  |     Links label to input. Tests accessibility.
  |
  |-- By text content (headings, paragraphs) -->
  |     getByText(/order confirmed/i)
  |     For non-interactive text content.
  |
  |-- By placeholder (no visible label) -->
  |     getByPlaceholderText(/search/i)
  |     Last resort before getByTestId.
  |
  |-- By test ID (absolutely no other option) -->
        getByTestId('order-list')
        Brittle. Avoids user-facing queries. Document why.

Mock Strategy Decision Tree

What does the component depend on?
  |-- API calls -->
  |     MSW (Mock Service Worker) — intercepts at network level
  |     No module mocking needed, tests use real fetch
  |
  |-- Third-party libraries (auth, analytics) -->
  |     Module mock: vi.mock('@auth/client')
  |     Only for libraries where MSW can't intercept
  |
  |-- Context / providers -->
  |     Wrap in test provider with controlled values
  |     Test with different provider values
  |
  |-- Feature flags -->
        MockFlagClient with specific flag values
        Test enabled and disabled states

Workflow

Step 1: Query Priority

Query When to Use
getByRole Preferred. Finds by ARIA role + accessible name.
getByLabelText Form fields. Links label to input via for/id or aria-labelledby.
getByPlaceholderText Only if no label exists. Last resort before getByTestId.
getByText Non-interactive elements (paragraphs, headings, spans).
getByTestId Absolute last resort. Brittle — avoids user-facing queries.

Step 2: Component Test Structure

describe('UserForm', () => {
  const setup = () => {
    const onSubmit = vi.fn()
    render(<UserForm onSubmit={onSubmit} />)
    return { onSubmit }
  }

  it('should show validation error when email is invalid', async () => {
    setup()
    const emailInput = screen.getByLabelText(/email/i)
    await userEvent.type(emailInput, 'invalid-email')
    await userEvent.click(screen.getByRole('button', { name: /submit/i }))
    expect(screen.getByText(/valid email/i)).toBeInTheDocument()
  })
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • references/component-test-patterns.md
  • references/msw-api-mocking.md
  • references/testing-ci.md
  • references/testing-library-guide.md
  • references/testing-patterns.md
  • references/testing-tools.md

FAQ

Что делает скилл frontend-testing?

Use when the user asks about frontend testing, component tests with Testing Library, Vitest or Jest, userEvent, mocking APIs with MSW, Playwright or Cypress for critical journeys, and what to test in the UI. Produces a test strategy and component/E2E tests. Not for Storybook stories (use frontend-storybook) or cross-team E2E suites (use quality-e2e-testing).

Как установить скилл frontend-testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл frontend-testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить frontend-testing с