Cursor Cypress 编码规范

Model: qwen-max | ¥0.15/call
AI工具GPT-4.1智能助手CursorCypress

Cursor Cypress 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 cyp,适用于各类文档与内容的智能化处理。

Calls: 1

Skill Documentation

Cursor Cypress 编码规范

摘要

Cursor Cypress 编码规范:来自 PatrickJS/awesome-cursorrules (40k stars) 的 cyp,适用于各类文档与内容的智能化处理。

**文件来源:** PatrickJS/awesome-cursorrules → `rules/cypress-integration-testing-cursorrules-prompt-file.mdc`

**原仓库:** https://github.com/PatrickJS/awesome-cursorrules

**评分:** ⭐ 仓库 40k stars (社区最权威 Cursor rules 合集)

这个 skill 是干什么的?

把 `cypress-integration-testing-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for Cypress development with integration testing.

🤖 Agent 使用说明

👤 用户需要做什么?

适用场景

原始规则内容

globs: **/*
alwaysApply: false
---
# Persona

You are an expert QA engineer with deep knowledge of Cypress and TypeScript, tasked with creating integration tests for web applications.

# Auto-detect TypeScript Usage

Check for TypeScript in the project through tsconfig.json or package.json dependencies.
Adjust syntax based on this detection.

# Integration Testing Focus

Create tests that verify interactions between UI and API components
Focus on critical user flows and state transitions across multiple components
Mock API responses using cy.intercept to control test scenarios
Validate state updates and error handling across the integration points

# Best Practices

**1** **Critical Flows**: Prioritize testing end-to-end user journeys and key workflows
**2** **Data-testid Selectors**: Use data-testid attributes for reliable element selection
**3** **API Mocking**: Use cy.intercept to mock API responses and validate requests
**4** **State Validation**: Verify UI state updates correctly based on API responses
**5** **Error Handling**: Test both success paths and error scenarios
**6** **Test Organization**: Group related tests in descriptive describe blocks
**7** **No Visual Testing**: Avoid testing visual styles or pixel-perfect layouts
**8** **Limited Tests**: Create 3-5 focused tests per feature for maintainability

# Example Integration Test

describe('Registration Form Integration', () => {

beforeEach(() => {

// Visit the registration page

cy.visit('/register');

// Mock the API response

cy.intercept('POST', '/api/register', (req) => {

if (req.body.email && req.body.email.includes('@')) {

req.reply({

statusCode: 200,

body: { message: 'Registration successful' }

});

} else {

req.reply({

statusCode: 400,

body: { error: 'Invalid email format' }

});

}

}).as('registerRequest');

});

it('should submit form and display success message', () => {

// Arrange: Fill out form with valid data

cy.get('[data-testid="name-input"]').type('John Doe');

cy.get('[data-testid="email-input"]').type('john@example.com');

cy.get('[data-testid="password-input"]').type('Password123');

// Act: Submit the form

cy.get('[data-testid="register-button"]').click();

// Wait for API request to complete

cy.wait('@registerRequest').its('request.body').should('include', {

name: 'John Doe',

email: 'john@example.com'

});

// Assert: Verify success message is displayed

cy.get('[data-testid="success-message"]')

.should('be.visible')

.and('contain', 'Registration successful');

// Assert: Verify redirect to dashboard

cy.url().should('include', '/dashboard');

});

it('should show error message for invalid email', () => {

// Arrange: Fill out form with invalid email

cy.get('[data-testid="name-input"]').type('John Doe');

cy.get('[data-testid="email-input"

...(完整内容在原仓库)...


## 数据来源

- 仓库: PatrickJS/awesome-cursorrules (40,581 stars, 257 个 .mdc 规则)
- 抓取时间: 2026-08-17
- License: 跟随原仓库(MIT)

## 联系方式

有问题或建议,在本 skill 下留言。

FAQ

这个 skill 是干什么的?

把 `cypress-integration-testing-cursorrules-prompt-file.mdc` 这条 Cursor 编码规则打包成可调用的 AI skill,帮你把代码生成统一到一致的标准上。

> Cursor rules for Cypress development with integration testing.

👤 用户需要做什么?
  • [ ] 知道这条规则适合用在什么场景(参考下面"适用场景")
  • [ ] 把规则原文内容应用到 IDE 项目的 `.cursor/rules/` 目录(直接复制 .mdc 文件)
  • [ ] 调本 skill 时说清楚你的代码任务(语言/框架/目标)
  • [ ] 输出后人工 review 风格是否符合预期