Skip to content
Back to skills

Cypress

ASecurity

- **Layer**: domain - **Category**: testing - **Risk Level**: low - **Triggers**: cypress, e2e test, end-to-end test, integration test, cy.get, cy.intercept

  • 2 stars
  • 0 votes
  • 0 copies
  • 8 views
  • Added October 26, 2026
testingjavascriptgojavareacttestingdebuggingapi

Works with

  • cli
  • api

Security analysis

A100/100

Scanned October 26, 2026

npx -y skills add nhan03bit/ultrathink --skill cypress --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cypress?

Add the live security badge to your README. It updates with every re-scan.

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

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

Download with Pro
SKILL.md
# Cypress

- **Layer**: domain
- **Category**: testing
- **Risk Level**: low
- **Triggers**: cypress, e2e test, end-to-end test, integration test, cy.get, cy.intercept

## Overview

JavaScript end-to-end testing framework that runs in the browser alongside your app. Features time-travel debugging, automatic waiting, real-time reloads, and network request stubbing.

## When to Use

- Writing end-to-end or integration tests for web applications
- Testing user flows across multiple pages or components
- Validating API interactions with request interception
- Component-level testing in isolation (Cypress Component Testing)
- Debugging flaky or failing UI tests

## Key Patterns

### Commands and Chaining
Cypress commands are asynchronous and chainable. Use `cy.get('[data-cy="submit"]')`, `cy.contains('Text')`, `.click()`, `.type('input')`, `.should('be.visible')`. Never assign return values to variables — chain assertions instead.

### Custom Commands
Extend Cypress via `Cypress.Commands.add('login', (email, pw) => { ... })` in `cypress/support/commands.ts`. Use for repeated flows like authentication. Type with `declare namespace Cypress { interface Chainable { ... } }`.

### Fixtures and Test Data
Store JSON fixtures in `cypress/fixtures/`. Load with `cy.fixture('user.json')` or reference in `cy.intercept()` responses. Keep fixtures minimal and deterministic.

### Network Interception
Use `cy.intercept('GET', '/api/users', { fixture: 'users.json' }).as('getUsers')` to stub or spy on requests. Wait with `cy.wait('@getUsers')`. Intercept before the action that triggers the request.

### Component Testing
Mount components with `cy.mount(<Component />)` in `cypress/component/` specs. Configure via `component` key in `cypress.config.ts`. Useful for testing components in isolation with full DOM access.

### Best Practices
- Use `data-cy` attributes for selectors — resilient to CSS/markup changes
- Avoid `cy.wait(ms)` — use `cy.intercept` aliases or assertions instead
- Each test should be independent — use `beforeEach` for setup, never rely on test order
- Keep tests deterministic by controlling data via fixtures and intercepts

### Screenshots, Videos, and Config
Cypress auto-captures screenshots on failure and records video in headless mode. Configure in `cypress.config.ts`: `screenshotsFolder`, `videosFolder`, `viewportWidth`, `baseUrl`, `retries`.

### Environment Variables and CI
Use `cypress.env.json` or `CYPRESS_*` env vars for environment-specific config. Access via `Cypress.env('key')`. In CI, run `npx cypress run --record --key <key>` with parallelization via `--parallel`.

## Anti-Patterns

- **Coupling to CSS classes or markup structure** — use `data-cy` attributes instead
- **Arbitrary waits** (`cy.wait(3000)`) — use intercept aliases or retry-able assertions
- **Sharing state between tests** — each `it()` block must be self-contained
- **Testing third-party sites** — only test what you control
- **Using the UI for repetitive setup** — use `cy.request()` or `cy.session()` for auth

## Related Skills

`test` | `testing-patterns` | `playwright` | `react`

Attribution

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

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.