Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Cypress Component Testing

ASecurity

Master Cypress component testing, React/Vue/Svelte mounting, component isolation, custom command creation, network stubbing, and visual snapshot assertions. Trigger when building or testing isolated UI components with Cypress Component Testing (CT).

8 stars
0 votes
0 copies
0 views
Added 9/29/2026
ai-agentstypescriptgobashreactvuenodetestingapi

Works with

cliapi

Security Analysis

A100/100

Scanned 9/29/2026

$npx -y skills add hamzabellouch/agent-skills --skill cypress-component-testing --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cypress Component Testing?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Cypress Component Testing
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hamzabellouch-cypress-component-testing/badge)](https://www.skillsdirectory.com/skills/hamzabellouch-cypress-component-testing)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: cypress-component-testing
metadata:
  category: QA and E2E Automation Testing
description: Master Cypress component testing, React/Vue/Svelte mounting, component isolation, custom command creation, network stubbing, and visual snapshot assertions. Trigger when building or testing isolated UI components with Cypress Component Testing (CT).
compatibility: Node.js 18+, Cypress 12.0+, React / Vue / Svelte, Vite / Webpack
---

# Cypress Component Testing Skill Guide

This skill provides production standards, configuration structures, and execution practices for testing isolated UI components using Cypress Component Testing.

---

## 1. Directory Structure & Architecture

Organize component tests alongside component source files or in dedicated `cypress/component/` hierarchies:

```text
src/
├── components/
│   ├── Button/
│   │   ├── Button.tsx
│   │   └── Button.cy.tsx          # Component test specification
│   └── UserCard/
│       ├── UserCard.tsx
│       └── UserCard.cy.tsx
cypress/
├── config/
│   └── cypress.config.ts          # Cypress configuration file
└── support/
    ├── component.ts               # Global component test setup & imports
    ├── component-index.html       # HTML template container for mounted components
    └── commands.ts                # Custom Cypress commands
```

---

## 2. Configuration Standard (`cypress.config.ts` & `support/component.ts`)

### A. Cypress Configuration (`cypress.config.ts`)

```typescript
import { defineConfig } from 'cypress';

export default defineConfig({
  component: {
    devServer: {
      framework: 'react',
      bundler: 'vite',
    },
    specPattern: 'src/**/*.cy.{js,ts,jsx,tsx}',
    supportFile: 'cypress/support/component.ts',
    indexHtmlFile: 'cypress/support/component-index.html',
    viewportWidth: 1024,
    viewportHeight: 768,
    video: false,
    screenshotOnRunFailure: true,
  },
});
```

### B. Support Setup (`cypress/support/component.ts`)

```typescript
import './commands';
import { mount } from 'cypress/react18';
import '../../src/styles/globals.css'; // Import global CSS styles

// Declare custom mount command type for TypeScript autocomplete
declare global {
  namespace Cypress {
    interface Chainable {
      mount: typeof mount;
    }
  }
}

Cypress.Commands.add('mount', mount);
```

---

## 3. Component Spec Implementation Examples

### A. Testing React Button Component (`Button.cy.tsx`)

```tsx
import React from 'react';
import { Button } from './Button';

describe('<Button /> Component', () => {
  it('renders with correct default label and variant styling', () => {
    cy.mount(<Button variant="primary">Click Me</Button>);
    
    cy.get('button')
      .should('be.visible')
      .and('have.text', 'Click Me')
      .and('have.class', 'bg-blue-600');
  });

  it('triggers onClick handler when clicked', () => {
    const onClickSpy = cy.spy().as('onClickSpy');
    
    cy.mount(<Button onClick={onClickSpy}>Submit</Button>);
    cy.get('button').click();
    
    cy.get('@onClickSpy').should('have.been.calledOnce');
  });

  it('disables interactions when disabled prop is set', () => {
    const onClickSpy = cy.spy().as('onClickSpy');
    
    cy.mount(<Button disabled onClick={onClickSpy}>Disabled</Button>);
    
    cy.get('button')
      .should('be.disabled')
      .and('have.attr', 'aria-disabled', 'true');
      
    cy.get('@onClickSpy').should('not.have.been.called');
  });
});
```

### B. Component Test with Network Interception (`UserCard.cy.tsx`)

```tsx
import React from 'react';
import { UserCard } from './UserCard';

describe('<UserCard /> Component', () => {
  it('displays loading state and fetches user data', () => {
    // Intercept component-level fetch request
    cy.intercept('GET', '/api/users/usr_100', {
      statusCode: 200,
      body: {
        id: 'usr_100',
        name: 'Jane Doe',
        role: 'Administrator',
        avatarUrl: 'https://example.com/avatar.png',
      },
    }).as('getUser');

    cy.mount(<UserCard userId="usr_100" />);

    // Assert initial loading indicator
    cy.get('[data-testid="skeleton-loader"]').should('be.visible');

    // Wait for network request to resolve and verify UI update
    cy.wait('@getUser');
    cy.get('[data-testid="user-name"]').should('have.text', 'Jane Doe');
    cy.get('[data-testid="user-role"]').should('have.text', 'Administrator');
  });
});
```

---

## 4. Execution Commands

```bash
# Run component tests headlessly in CI mode
npx cypress run --component

# Run component tests targeting a specific browser
npx cypress run --component --browser chrome

# Launch interactive Cypress Component Test runner UI
npx cypress open --component
```

---

## 5. Anti-Patterns & Best Practices

| Anti-Pattern | Operational Failure | Production Best Practice |
| :--- | :--- | :--- |
| **Testing full pages with Component Testing** | Bypasses actual page routing and integration layers. | Use Cypress CT for individual components; use Playwright/Cypress E2E for full pages. |
| **Omitting CSS imports in `component.ts`** | Components render without styles, causing layout bugs in snapshots. | Import global CSS, Tailwind, or theme providers in `cypress/support/component.ts`. |
| **Using `cy.wait(1000)` instead of aliases** | Creates non-deterministic race conditions and test flakiness. | Use `cy.intercept().as('alias')` and wait for `cy.wait('@alias')`. |
| **Relying on implementation details (`.parent().children().eq(2)`)** | Spec fails whenever internal markup changes despite identical behavior. | Query using accessibility roles, text content, or explicit `data-testid` attributes. |

Attribution

hamzabellouchhamzabellouch
View sourceSee grades on GitHubMore from hamzabellouch →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698461 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →