Cypress

From InugamiDev/ultrathink-oss · View interactive version

Cypress is an AI agent skill from the GitHub repository InugamiDev/ultrathink-oss. - **Triggers**: cypress, e2e test, end-to-end test, integration test, cy.get, cy.intercept

How to use this skill

Skill file

Cypress

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

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

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

Related Skills

test | testing-patterns | playwright | react

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.