When to use this skill
Use this skill whenever the user wants to:
- Set up Cypress for end-to-end testing
- Write Cypress test cases
- Configure Cypress for component testing
- Integrate Cypress with CI/CD pipelines
- Use Cypress commands and assertions
- Debug Cypress tests
- Optimize Cypress test performance
- Migrate from other testing frameworks to Cypress
- Use Cypress with different frameworks (React, Vue, Angular, Svelte)
- Configure Cypress for different environments
How to use this skill
This skill is organized to match the Cypress official documentation structure (https://docs.cypress.io/app/get-started/why-cypress, https://docs.cypress.io/api/table-of-contents). When working with Cypress:
Identify the topic from the user's request:
- Getting Started/快速开始 →
examples/get-started/
- Core Concepts/核心概念 →
examples/core-concepts/
- Component Testing/组件测试 →
examples/component-testing/
- End-to-End Testing/E2E测试 →
examples/end-to-end-testing/
- Continuous Integration/持续集成 →
examples/continuous-integration/
- Guides/指南 →
examples/guides/
- References/参考 →
examples/references/
- API Reference/API 参考 →
api/
Load the appropriate example file from the examples/ directory:
Getting Started (快速开始) - examples/get-started/:
examples/get-started/install-cypress.md
examples/get-started/open-the-app.md
examples/get-started/why-cypress.md
Core Concepts (核心概念) - examples/core-concepts/:
examples/core-concepts/best-practices.md
examples/core-concepts/interacting-with-elements.md
examples/core-concepts/introduction-to-cypress.md
examples/core-concepts/open-mode.md
examples/core-concepts/retry-ability.md
examples/core-concepts/test-isolation.md
examples/core-concepts/testing-types.md
examples/core-concepts/variables-and-aliases.md
examples/core-concepts/writing-and-organizing-tests.md
Component Testing (组件测试) - examples/component-testing/:
examples/component-testing/angular/api.md
examples/component-testing/angular/examples.md
examples/component-testing/angular/overview.md
examples/component-testing/component-framework-configuration.md
examples/component-testing/custom-frameworks.md
examples/component-testing/get-started.md
examples/component-testing/react/api.md
examples/component-testing/react/examples.md
examples/component-testing/react/overview.md
examples/component-testing/styling-components.md
examples/component-testing/svelte/api.md
examples/component-testing/svelte/examples.md
examples/component-testing/svelte/overview.md
examples/component-testing/vue/api.md
examples/component-testing/vue/examples.md
examples/component-testing/vue/overview.md
End-to-End Testing (E2E测试) - examples/end-to-end-testing/:
examples/end-to-end-testing/testing-your-app.md
examples/end-to-end-testing/writing-your-first-end-to-end-test.md
Continuous Integration (持续集成) - examples/continuous-integration/:
examples/continuous-integration/aws-codebuild.md
examples/continuous-integration/bitbucket-pipelines.md
examples/continuous-integration/circleci.md
examples/continuous-integration/github-actions.md
examples/continuous-integration/gitlab-ci.md
examples/continuous-integration/overview.md
Guides (指南) - examples/guides/:
examples/guides/accessibility-testing.md
examples/guides/authentication-testing/amazon-cognito-authentication.md
examples/guides/authentication-testing/auth0-authentication.md
examples/guides/authentication-testing/azure-active-directory-authentication.md
examples/guides/authentication-testing/google-authentication.md
examples/guides/authentication-testing/okta-authentication.md
examples/guides/authentication-testing/social-authentication.md
examples/guides/conditional-testing.md
examples/guides/cross-browser-testing.md
examples/guides/cross-origin-testing.md
examples/guides/cypress-studio.md
examples/guides/debugging.md
examples/guides/migration/protractor-to-cypress.md
examples/guides/migration/selenium-to-cypress.md
examples/guides/network-requests.md
examples/guides/screenshots-and-videos.md
examples/guides/stubs-spies-and-clocks.md
examples/guides/test-retries.md
References (参考) - examples/references/:
examples/references/advanced-installation.md
examples/references/assertions.md
examples/references/bundled-libraries.md
examples/references/changelog.md
examples/references/client-certificates.md
examples/references/command-line.md
examples/references/configuration.md
examples/references/content-security-policy.md
examples/references/environment-variables.md
examples/references/error-messages.md
examples/references/experiments.md
examples/references/launching-browsers.md
examples/references/migration-guide.md
examples/references/module-api.md
examples/references/proxy-configuration.md
examples/references/recipes.md
examples/references/roadmap.md
examples/references/trade-offs.md
examples/references/troubleshooting.md
Other Sections:
examples/faq.md
examples/plugins/plugins-guide.md
examples/plugins/plugins-list.md
examples/tooling/IDE-integration.md
examples/tooling/code-coverage.md
examples/tooling/reporters.md
examples/tooling/typescript-support.md
examples/tooling/visual-testing.md
Reference API documentation in the api/ directory when needed:
Commands API - api/commands/:
api/commands/and.md
api/commands/as.md
api/commands/blur.md
api/commands/check.md
api/commands/children.md
api/commands/clear.md
api/commands/clearallcookies.md
api/commands/clearalllocalstorage.md
api/commands/clearallsessionstorage.md
api/commands/clearcookie.md
api/commands/clearcookies.md
api/commands/clearlocalstorage.md
api/commands/click.md
api/commands/clock.md
api/commands/closest.md
api/commands/contains.md
api/commands/dblclick.md
api/commands/debug.md
api/commands/document.md
api/commands/each.md
api/commands/end.md
api/commands/eq.md
api/commands/exec.md
api/commands/filter.md
api/commands/find.md
api/commands/first.md
api/commands/fixture.md
api/commands/focus.md
api/commands/focused.md
api/commands/get.md
api/commands/getallcookies.md
api/commands/getalllocalstorage.md
api/commands/getallsessionstorage.md
api/commands/getcookie.md
api/commands/getcookies.md
api/commands/go.md
api/commands/hash.md
api/commands/hover.md
api/commands/intercept.md
api/commands/invoke.md
api/commands/its.md
api/commands/last.md
api/commands/location.md
api/commands/log.md
api/commands/mount.md
api/commands/next.md
api/commands/nextall.md
api/commands/nextuntil.md
api/commands/not.md
api/commands/origin.md
- ... and 43 more command files
Cypress API - api/cypress-api/:
api/cypress-api/arch.md
api/cypress-api/browser.md
api/cypress-api/catalog-of-events.md
api/cypress-api/config.md
api/cypress-api/cookies.md
api/cypress-api/currentretry.md
api/cypress-api/currenttest.md
api/cypress-api/custom-commands.md
api/cypress-api/custom-queries.md
api/cypress-api/cypress-log.md
api/cypress-api/dom.md
api/cypress-api/element-selector-api.md
api/cypress-api/ensure.md
api/cypress-api/env.md
api/cypress-api/isbrowser.md
api/cypress-api/iscy.md
api/cypress-api/keyboard-api.md
api/cypress-api/platform.md
api/cypress-api/require.md
api/cypress-api/screenshot-api.md
api/cypress-api/session.md
api/cypress-api/spec.md
api/cypress-api/stop.md
api/cypress-api/testing-type.md
api/cypress-api/version.md
Node Events API - api/node-events/:
api/node-events/after-run-api.md
api/node-events/after-screenshot-api.md
api/node-events/after-spec-api.md
api/node-events/before-run-api.md
api/node-events/before-spec-api.md
api/node-events/browser-launch-api.md
api/node-events/configuration-api.md
api/node-events/overview.md
api/node-events/preprocessors-api.md
Utilities API - api/utilities/:
api/utilities/$.md
api/utilities/_.md
api/utilities/blob.md
api/utilities/buffer.md
api/utilities/minimatch.md
api/utilities/promise.md
api/utilities/sinon.md
Table of Contents - api/table-of-contents/:
Follow the specific instructions in that example file for syntax, structure, and best practices
Important Notes:
- All examples follow Cypress best practices
- Examples include both JavaScript and TypeScript versions where applicable
- Each example file includes parameters, returns, common errors, best practices, and scenarios
- Always check the example file for best practices and common patterns
Reference the official documentation when needed:
Best Practices
- Use data-cy attributes: Use data-cy attributes for stable, test-friendly selectors
- Avoid hard-coded waits: Leverage Cypress's built-in retry-ability instead of cy.wait()
- Keep tests isolated: Each test should be independent and not rely on other tests
- Use custom commands: Create custom commands for reusable test logic
- Follow assertion patterns: Use Cypress's built-in assertions for better error messages
- Configure properly: Set up cypress.config.js correctly for your project
- Use fixtures: Use fixtures for test data instead of hard-coding values
- Component testing: Use component testing for isolated component testing
- CI/CD integration: Configure Cypress properly for CI/CD environments
- Debug effectively: Use Cypress's debugging tools and commands
Resources
Keywords
Cypress, end-to-end testing, E2E testing, component testing, test automation, browser testing, test framework, assertions, commands, fixtures, CI/CD, continuous integration, test runner, 端到端测试, E2E测试, 组件测试, 测试自动化, 浏览器测试, 测试框架, 断言, 命令, 固定数据, 持续集成, 测试运行器
能力边界
✅ 适用场景
- 当你需要使用此技能对应的技术栈时
- 当项目需要遵循最佳实践时
- 当需要快速上手或深入理解核心概念时
⚠️ 需要注意
- 复杂业务逻辑需要结合具体场景调整
- 性能优化需要根据实际数据量评估
❌ 不适用场景
常见陷阱 (Gotchas)
- 版本兼容性:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异
- 配置文件格式:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查
- 环境变量:确保所有必要的环境变量已正确设置,敏感信息不要硬编码
- 依赖冲突:多版本共存时注意依赖冲突,使用 lock 文件锁定版本
- 性能陷阱:大数据量场景下注意性能优化,避免 N+1 查询等常见问题
使用流程
Step 1: 环境准备
确保开发环境已安装必要的依赖和工具。
Step 2: 配置初始化
根据项目需求进行基础配置。
Step 3: 核心功能使用
按照示例代码实现核心功能。
Step 4: 测试验证
运行测试确保功能正常。
Step 5: 部署上线
完成开发后进行部署和监控。
1---2name: cypress3description: Provides comprehensive guidance for Cypress end-to-end testing including commands, assertions, component testing, CI/CD integration, and best practices. Use when the user asks about Cypress, needs to write E2E tests, component tests, or configure Cypress for testing.4license: Complete terms in LICENSE.txt5---67## When to use this skill89Use this skill whenever the user wants to:10- Set up Cypress for end-to-end testing11- Write Cypress test cases12- Configure Cypress for component testing13- Integrate Cypress with CI/CD pipelines14- Use Cypress commands and assertions15- Debug Cypress tests16- Optimize Cypress test performance17- Migrate from other testing frameworks to Cypress18- Use Cypress with different frameworks (React, Vue, Angular, Svelte)19- Configure Cypress for different environments2021## How to use this skill2223This skill is organized to match the Cypress official documentation structure (https://docs.cypress.io/app/get-started/why-cypress, https://docs.cypress.io/api/table-of-contents). When working with Cypress:24251. **Identify the topic** from the user's request:26 - Getting Started/快速开始 → `examples/get-started/`27 - Core Concepts/核心概念 → `examples/core-concepts/`28 - Component Testing/组件测试 → `examples/component-testing/`29 - End-to-End Testing/E2E测试 → `examples/end-to-end-testing/`30 - Continuous Integration/持续集成 → `examples/continuous-integration/`31 - Guides/指南 → `examples/guides/`32 - References/参考 → `examples/references/`33 - API Reference/API 参考 → `api/`34352. **Load the appropriate example file** from the `examples/` directory:3637 **Getting Started (快速开始)** - `examples/get-started/`:38 - `examples/get-started/install-cypress.md`39 - `examples/get-started/open-the-app.md`40 - `examples/get-started/why-cypress.md`4142 **Core Concepts (核心概念)** - `examples/core-concepts/`:43 - `examples/core-concepts/best-practices.md`44 - `examples/core-concepts/interacting-with-elements.md`45 - `examples/core-concepts/introduction-to-cypress.md`46 - `examples/core-concepts/open-mode.md`47 - `examples/core-concepts/retry-ability.md`48 - `examples/core-concepts/test-isolation.md`49 - `examples/core-concepts/testing-types.md`50 - `examples/core-concepts/variables-and-aliases.md`51 - `examples/core-concepts/writing-and-organizing-tests.md`5253 **Component Testing (组件测试)** - `examples/component-testing/`:54 - `examples/component-testing/angular/api.md`55 - `examples/component-testing/angular/examples.md`56 - `examples/component-testing/angular/overview.md`57 - `examples/component-testing/component-framework-configuration.md`58 - `examples/component-testing/custom-frameworks.md`59 - `examples/component-testing/get-started.md`60 - `examples/component-testing/react/api.md`61 - `examples/component-testing/react/examples.md`62 - `examples/component-testing/react/overview.md`63 - `examples/component-testing/styling-components.md`64 - `examples/component-testing/svelte/api.md`65 - `examples/component-testing/svelte/examples.md`66 - `examples/component-testing/svelte/overview.md`67 - `examples/component-testing/vue/api.md`68 - `examples/component-testing/vue/examples.md`69 - `examples/component-testing/vue/overview.md`7071 **End-to-End Testing (E2E测试)** - `examples/end-to-end-testing/`:72 - `examples/end-to-end-testing/testing-your-app.md`73 - `examples/end-to-end-testing/writing-your-first-end-to-end-test.md`7475 **Continuous Integration (持续集成)** - `examples/continuous-integration/`:76 - `examples/continuous-integration/aws-codebuild.md`77 - `examples/continuous-integration/bitbucket-pipelines.md`78 - `examples/continuous-integration/circleci.md`79 - `examples/continuous-integration/github-actions.md`80 - `examples/continuous-integration/gitlab-ci.md`81 - `examples/continuous-integration/overview.md`8283 **Guides (指南)** - `examples/guides/`:84 - `examples/guides/accessibility-testing.md`85 - `examples/guides/authentication-testing/amazon-cognito-authentication.md`86 - `examples/guides/authentication-testing/auth0-authentication.md`87 - `examples/guides/authentication-testing/azure-active-directory-authentication.md`88 - `examples/guides/authentication-testing/google-authentication.md`89 - `examples/guides/authentication-testing/okta-authentication.md`90 - `examples/guides/authentication-testing/social-authentication.md`91 - `examples/guides/conditional-testing.md`92 - `examples/guides/cross-browser-testing.md`93 - `examples/guides/cross-origin-testing.md`94 - `examples/guides/cypress-studio.md`95 - `examples/guides/debugging.md`96 - `examples/guides/migration/protractor-to-cypress.md`97 - `examples/guides/migration/selenium-to-cypress.md`98 - `examples/guides/network-requests.md`99 - `examples/guides/screenshots-and-videos.md`100 - `examples/guides/stubs-spies-and-clocks.md`101 - `examples/guides/test-retries.md`102103 **References (参考)** - `examples/references/`:104 - `examples/references/advanced-installation.md`105 - `examples/references/assertions.md`106 - `examples/references/bundled-libraries.md`107 - `examples/references/changelog.md`108 - `examples/references/client-certificates.md`109 - `examples/references/command-line.md`110 - `examples/references/configuration.md`111 - `examples/references/content-security-policy.md`112 - `examples/references/environment-variables.md`113 - `examples/references/error-messages.md`114 - `examples/references/experiments.md`115 - `examples/references/launching-browsers.md`116 - `examples/references/migration-guide.md`117 - `examples/references/module-api.md`118 - `examples/references/proxy-configuration.md`119 - `examples/references/recipes.md`120 - `examples/references/roadmap.md`121 - `examples/references/trade-offs.md`122 - `examples/references/troubleshooting.md`123124 **Other Sections**:125 - `examples/faq.md`126 - `examples/plugins/plugins-guide.md`127 - `examples/plugins/plugins-list.md`128 - `examples/tooling/IDE-integration.md`129 - `examples/tooling/code-coverage.md`130 - `examples/tooling/reporters.md`131 - `examples/tooling/typescript-support.md`132 - `examples/tooling/visual-testing.md`1331343. **Reference API documentation** in the `api/` directory when needed:135136 **Commands API** - `api/commands/`:137 - `api/commands/and.md`138 - `api/commands/as.md`139 - `api/commands/blur.md`140 - `api/commands/check.md`141 - `api/commands/children.md`142 - `api/commands/clear.md`143 - `api/commands/clearallcookies.md`144 - `api/commands/clearalllocalstorage.md`145 - `api/commands/clearallsessionstorage.md`146 - `api/commands/clearcookie.md`147 - `api/commands/clearcookies.md`148 - `api/commands/clearlocalstorage.md`149 - `api/commands/click.md`150 - `api/commands/clock.md`151 - `api/commands/closest.md`152 - `api/commands/contains.md`153 - `api/commands/dblclick.md`154 - `api/commands/debug.md`155 - `api/commands/document.md`156 - `api/commands/each.md`157 - `api/commands/end.md`158 - `api/commands/eq.md`159 - `api/commands/exec.md`160 - `api/commands/filter.md`161 - `api/commands/find.md`162 - `api/commands/first.md`163 - `api/commands/fixture.md`164 - `api/commands/focus.md`165 - `api/commands/focused.md`166 - `api/commands/get.md`167 - `api/commands/getallcookies.md`168 - `api/commands/getalllocalstorage.md`169 - `api/commands/getallsessionstorage.md`170 - `api/commands/getcookie.md`171 - `api/commands/getcookies.md`172 - `api/commands/go.md`173 - `api/commands/hash.md`174 - `api/commands/hover.md`175 - `api/commands/intercept.md`176 - `api/commands/invoke.md`177 - `api/commands/its.md`178 - `api/commands/last.md`179 - `api/commands/location.md`180 - `api/commands/log.md`181 - `api/commands/mount.md`182 - `api/commands/next.md`183 - `api/commands/nextall.md`184 - `api/commands/nextuntil.md`185 - `api/commands/not.md`186 - `api/commands/origin.md`187 - ... and 43 more command files188189 **Cypress API** - `api/cypress-api/`:190 - `api/cypress-api/arch.md`191 - `api/cypress-api/browser.md`192 - `api/cypress-api/catalog-of-events.md`193 - `api/cypress-api/config.md`194 - `api/cypress-api/cookies.md`195 - `api/cypress-api/currentretry.md`196 - `api/cypress-api/currenttest.md`197 - `api/cypress-api/custom-commands.md`198 - `api/cypress-api/custom-queries.md`199 - `api/cypress-api/cypress-log.md`200 - `api/cypress-api/dom.md`201 - `api/cypress-api/element-selector-api.md`202 - `api/cypress-api/ensure.md`203 - `api/cypress-api/env.md`204 - `api/cypress-api/isbrowser.md`205 - `api/cypress-api/iscy.md`206 - `api/cypress-api/keyboard-api.md`207 - `api/cypress-api/platform.md`208 - `api/cypress-api/require.md`209 - `api/cypress-api/screenshot-api.md`210 - `api/cypress-api/session.md`211 - `api/cypress-api/spec.md`212 - `api/cypress-api/stop.md`213 - `api/cypress-api/testing-type.md`214 - `api/cypress-api/version.md`215216 **Node Events API** - `api/node-events/`:217 - `api/node-events/after-run-api.md`218 - `api/node-events/after-screenshot-api.md`219 - `api/node-events/after-spec-api.md`220 - `api/node-events/before-run-api.md`221 - `api/node-events/before-spec-api.md`222 - `api/node-events/browser-launch-api.md`223 - `api/node-events/configuration-api.md`224 - `api/node-events/overview.md`225 - `api/node-events/preprocessors-api.md`226227 **Utilities API** - `api/utilities/`:228 - `api/utilities/$.md`229 - `api/utilities/_.md`230 - `api/utilities/blob.md`231 - `api/utilities/buffer.md`232 - `api/utilities/minimatch.md`233 - `api/utilities/promise.md`234 - `api/utilities/sinon.md`235236 **Table of Contents** - `api/table-of-contents/`:2372384. **Follow the specific instructions** in that example file for syntax, structure, and best practices239240 **Important Notes**:241 - All examples follow Cypress best practices242 - Examples include both JavaScript and TypeScript versions where applicable243 - Each example file includes parameters, returns, common errors, best practices, and scenarios244 - Always check the example file for best practices and common patterns2452465. **Reference the official documentation** when needed:247 - Getting Started: https://docs.cypress.io/app/get-started/why-cypress248 - API Reference: https://docs.cypress.io/api/table-of-contents249250## Best Practices2512521. **Use data-cy attributes**: Use data-cy attributes for stable, test-friendly selectors2532. **Avoid hard-coded waits**: Leverage Cypress's built-in retry-ability instead of cy.wait()2543. **Keep tests isolated**: Each test should be independent and not rely on other tests2554. **Use custom commands**: Create custom commands for reusable test logic2565. **Follow assertion patterns**: Use Cypress's built-in assertions for better error messages2576. **Configure properly**: Set up cypress.config.js correctly for your project2587. **Use fixtures**: Use fixtures for test data instead of hard-coding values2598. **Component testing**: Use component testing for isolated component testing2609. **CI/CD integration**: Configure Cypress properly for CI/CD environments26110. **Debug effectively**: Use Cypress's debugging tools and commands262263## Resources264265- **Official Documentation**: https://docs.cypress.io/266- **Getting Started**: https://docs.cypress.io/app/get-started/why-cypress267- **API Reference**: https://docs.cypress.io/api/table-of-contents268- **GitHub Repository**: https://github.com/cypress-io/cypress269270## Keywords271272Cypress, end-to-end testing, E2E testing, component testing, test automation, browser testing, test framework, assertions, commands, fixtures, CI/CD, continuous integration, test runner, 端到端测试, E2E测试, 组件测试, 测试自动化, 浏览器测试, 测试框架, 断言, 命令, 固定数据, 持续集成, 测试运行器273274## 能力边界275276### ✅ 适用场景277- 当你需要使用此技能对应的技术栈时278- 当项目需要遵循最佳实践时279- 当需要快速上手或深入理解核心概念时280281### ⚠️ 需要注意282- 复杂业务逻辑需要结合具体场景调整283- 性能优化需要根据实际数据量评估284285### ❌ 不适用场景286- 不相关的技术栈或框架287- 需要完全自定义的特殊场景288289## 常见陷阱 (Gotchas)2902911. **版本兼容性**:注意框架版本与依赖库的兼容性,不同版本 API 可能有差异2922. **配置文件格式**:配置文件格式错误是最常见的问题,建议使用编辑器的语法检查2933. **环境变量**:确保所有必要的环境变量已正确设置,敏感信息不要硬编码2944. **依赖冲突**:多版本共存时注意依赖冲突,使用 lock 文件锁定版本2955. **性能陷阱**:大数据量场景下注意性能优化,避免 N+1 查询等常见问题296297## 使用流程298299### Step 1: 环境准备300确保开发环境已安装必要的依赖和工具。301302### Step 2: 配置初始化303根据项目需求进行基础配置。304305### Step 3: 核心功能使用306按照示例代码实现核心功能。307308### Step 4: 测试验证309运行测试确保功能正常。310311### Step 5: 部署上线312完成开发后进行部署和监控。