cypress
Installation
SKILL.md
Cypress
Overview
Cypress is an end-to-end testing framework for web applications that runs tests directly in the browser for fast, reliable feedback. It provides element selection, network interception, component testing, and CI integration with parallelization and video recording.
Instructions
- When selecting elements, use
data-testidordata-cyattributes withcy.get("[data-testid='submit']")instead of CSS classes or IDs for resilient selectors. - When testing interactions, use
cy.get().type(),.click(),.select(), and.check()for user actions, and chain.should()assertions for expected outcomes. - When handling API calls, use
cy.intercept()to stub external APIs with fixtures or spy on requests, andcy.wait("@alias")after actions that trigger calls instead ofcy.wait(ms). - When writing custom commands, use
Cypress.Commands.add()for reusable patterns like login, database seeding, and common workflows, with TypeScript declarations for IntelliSense. - When testing components, use
cy.mount()with framework-specific mounting libraries (@cypress/react,@cypress/vue) to test components in isolation. - When configuring CI, use
cypress run --record --keyfor Cypress Cloud integration with--parallelto split tests across machines, and--browserto specify the browser. - When setting up the project, configure
cypress.config.tswithbaseUrl, viewport dimensions, timeouts, and environment variables.