Token导航 LogoToken导航TokenDH.com
开发操作浏览器github未标认证来源可访问clear审计通过

cypressCypress 测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

11,187

周安装

457

GitHub Stars

39

下载量

3,583
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:cypress(Cypress 测试)
来源仓库:https://github.com/bobmatnyc/claude-mpm-skills
仓库路径:skills/cypress
安装命令:
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill cypress
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill cypress

简介

cypress 提供端到端与组件级浏览器自动化测试支持。

  • 擅长网络拦截、时间旅行调试和本地开发快速反馈。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。
  • 推荐使用 data-testid 稳定定位元素,避免脆弱选择器。
  • 需区分测试环境与生产环境,防止误操作真实服务。
  • cypress 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Cypress (E2E + Component Testing)

Overview

Cypress runs browser automation with first-class network control, time-travel debugging, and a strong local dev workflow. Use it for critical path E2E tests and for component tests when browser-level rendering matters.

Quick Start

Install and open

npm i -D cypress
npx cypress open

Minimal spec

// cypress/e2e/health.cy.ts
describe("health", () => {
  it("loads", () => {
    cy.visit("/");
    cy.contains("Hello").should("be.visible");
  });
});

Core Patterns

1) Stable selectors

Prefer data-testid (or data-cy) attributes for selectors. Avoid brittle CSS chains and text-only selectors for critical interactions.

<button data-testid="save-user">Save</button>
cy.get('[data-testid="save-user"]').click();

2) Deterministic waiting (avoid fixed sleeps)

Wait on app-visible conditions or network aliases rather than cy.wait(1000).

cy.intercept("GET", "/api/users/*").as("getUser");
cy.visit("/users/1");
cy.wait("@getUser");
cy.get('[data-testid="user-email"]').should("not.be.empty");

3) Network control with cy.intercept

Stub responses for deterministic tests and speed. Keep a small set of “real backend” smoke tests separate.

cy.intercept("GET", "/api/users/1", {
  statusCode: 200,
  body: { id: "1", email: "a@example.com" },
}).as("getUser");

4) Authentication strategies

Prefer cy.session to cache login for speed and stability.

// cypress/support/commands.ts
Cypress.Commands.add("login", () => {
  cy.session("user", () => {
    cy.request("POST", "/api/auth/login", {
      email: "test@example.com",
      password: "password",
    });
  });
});
// e2e spec
beforeEach(() => {
  cy.login();
});

Component Testing

Run component tests to validate UI behavior in isolation while keeping browser rendering.

npx cypress open --component
// cypress/component/Button.cy.tsx
import React from "react";
import Button from "../../src/Button";

describe("<Button />", () => {
  it("clicks", () => {
    cy.mount(<Button onClick={cy.stub().as("onClick")}>Save</Button>);
    cy.contains("Save").click();
    cy.get("@onClick").should("have.been.calledOnce");
  });
});

CI Patterns

Artifacts (videos/screenshots)

Store artifacts for failed runs and keep videos optional to reduce storage.

// cypress.config.ts
import { defineConfig } from "cypress";

export default defineConfig({
  video: false,
  screenshotOnRunFailure: true,
  retries: { runMode: 2, openMode: 0 },
});

Parallelization (Cypress Cloud)

Parallelize long E2E suites via Cypress Cloud when runtime dominates feedback loops.

Anti-Patterns

  • Use cy.wait(1000) as a synchronization mechanism.
  • Select elements via deep CSS paths.
  • Mix heavy network stubbing with “real backend” assertions in the same spec.
  • Depend on test order; isolate state with cy.session and per-test setup.

Troubleshooting

Symptom: flaky click or element not found

Actions:

  • Add a data-testid hook for the element.
  • Assert visibility before interaction (should("be.visible")).
  • Wait on network alias for the data that renders the element.

Symptom: tests fail only in CI

Actions:

  • Increase run-mode retries and record screenshots on failure.
  • Verify viewport and baseUrl config match CI environment.
  • Eliminate reliance on local-only seed data; create data via API calls.

Resources

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

25.77%
按下载量换算923

OpenCode

22.73%
按下载量换算814

Cursor

15.68%
按下载量换算562

Gemini CLI

13.79%
按下载量换算494

Antigravity

8.35%
按下载量换算299

github-copilot

3.74%
按下载量换算134

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills