Cypress advanced

From TheBushidoCollective/han · View interactive version

Cypress advanced is an AI agent skill from the GitHub repository TheBushidoCollective/han. Use when advanced Cypress features including custom commands, plugins, and network stubbing.

How to use this skill

Skill file

cypress advanced

Master advanced Cypress features including custom commands, plugins, and network stubbing. This skill provides comprehensive coverage of essential concepts, patterns, and best practices for professional Cypress development.

Overview

Cypress is a powerful tool for javascript development, providing robust capabilities for maintaining code quality and ensuring reliable software delivery. This skill covers the fundamental through advanced aspects of working with Cypress.

Installation and Setup

Basic Installation

Setting up Cypress requires proper installation and configuration in your development environment.

# Installation command specific to Cypress
# Follow official documentation for latest version

Project Configuration

Create appropriate configuration files and setup for your project structure:

Core Concepts

Fundamental Principles

Understanding the core principles of Cypress is essential for effective usage:

  1. Architecture - How Cypress is structured and operates
  2. Configuration - Setting up and customizing behavior
  3. Integration - Working with other tools and frameworks
  4. Best Practices - Industry-standard approaches

Key Features

Cypress provides several key features that make it valuable:

Configuration Strategy

Proper configuration ensures Cypress works optimally:

Advanced Usage

For complex scenarios, Cypress offers advanced capabilities:

Code Examples

Example 1: Basic Setup

// Basic Cypress setup
// Demonstrates fundamental usage patterns
// Shows proper initialization and configuration

// Core setup code
function basicSetup() {
  // Initialize framework
  // Configure basic options
  // Return configured instance
}

// Usage example
const instance = basicSetup();

Example 2: Configuration

// Configuration example for Cypress
// Shows how to properly configure
// Includes common options and patterns

// Configuration object
const config = {
  option1: 'value1',
  option2: 'value2',
  advanced: {
    setting1: true,
    setting2: false
  }
};

// Apply configuration
function applyConfig(config) {
  // Validation logic
  // Application logic
  // Return result
}

Example 3: Advanced Pattern

// Advanced usage pattern
// Demonstrates sophisticated techniques
// Shows best practices in action

function advancedPattern() {
  // Setup phase
  // Execution phase
  // Cleanup phase
}

Example 4: Integration

// Integration with other tools
// Shows real-world usage
// Demonstrates interoperability

function integrationExample() {
  // Setup integration
  // Execute workflow
  // Handle results
}

Example 5: Error Handling

// Proper error handling approach
// Defensive programming patterns
// Graceful degradation

function withErrorHandling() {
  try {
    // Main logic
  } catch (error) {
    // Error recovery
  } finally {
    // Cleanup
  }
}

Example 6: Performance Optimization

// Performance-optimized implementation
// Shows efficiency techniques
// Demonstrates best practices

function optimizedApproach() {
  // Efficient implementation
  // Resource management
  // Performance monitoring
}

Example 7: Testing

// Testing approach for Cypress
// Unit test examples
// Integration test patterns

function testExample() {
  // Test setup
  // Execution
  // Assertions
  // Teardown
}

Example 8: Production Usage

// Production-ready implementation
// Includes monitoring and logging
// Error recovery and resilience

function productionExample() {
  // Production configuration
  // Monitoring setup
  // Error handling
  // Logging
}

Best Practices

  1. Follow conventions - Adhere to established naming and structural patterns for consistency
  2. Configure appropriately - Set up framework configuration that matches project requirements
  3. Validate inputs - Always validate and sanitize inputs before processing
  4. Handle errors gracefully - Implement comprehensive error handling and recovery
  5. Document decisions - Comment configuration choices and non-obvious implementations
  6. Test thoroughly - Write comprehensive tests for all functionality
  7. Optimize performance - Profile and optimize critical paths
  8. Maintain security - Follow security best practices and guidelines
  9. Keep updated - Regularly update framework and dependencies
  10. Monitor production - Implement logging and monitoring for production systems

Common Pitfalls

  1. Incorrect configuration - Misconfiguration leads to unexpected behavior and bugs
  2. Missing error handling - Not handling edge cases causes production issues
  3. Poor performance - Not optimizing leads to scalability problems
  4. Inadequate testing - Insufficient test coverage misses bugs
  5. Security vulnerabilities - Not following security best practices exposes risks
  6. Tight coupling - Poor architecture makes maintenance difficult
  7. Ignoring warnings - Dismissing framework warnings leads to future problems
  8. Outdated dependencies - Using old versions exposes security risks
  9. No monitoring - Lack of observability makes debugging difficult
  10. Inconsistent standards - Team inconsistency reduces code quality

Advanced Topics

Customization

Cypress allows extensive customization for specific needs:

Performance Tuning

Optimize Cypress performance for production:

CI/CD Integration

Integrate Cypress into continuous integration pipelines:

Troubleshooting

Common issues and their solutions:

When to Use This Skill

Additional Resources

Documentation

Tools and Utilities

Community

Conclusion

Mastering Cypress requires understanding both fundamentals and advanced concepts. This skill provides the foundation for professional-grade usage, from initial setup through production deployment. Apply these principles consistently for best results.

Detailed Configuration Examples

Configuration Option 1

Comprehensive configuration example demonstrating best practices and common patterns used in production environments.

# Detailed configuration setup
# Includes all necessary options
# Optimized for production use

Configuration Option 2

Alternative configuration approach for different use cases, showing flexibility and adaptability of the framework.

# Alternative configuration
# Different optimization strategy
# Suitable for specific scenarios

Configuration Option 3

Advanced configuration for complex environments with multiple requirements and constraints.

# Advanced configuration
# Handles complex scenarios
# Production-ready setup

Advanced Usage Patterns

Pattern 1: Modular Organization

Organize your setup in a modular way to improve maintainability and scalability across large projects.

Implementation details:

Pattern 2: Performance Optimization

Optimize for performance in production environments with proven strategies and techniques.

Key considerations:

Pattern 3: Error Recovery

Implement robust error recovery mechanisms to handle failures gracefully.

Recovery strategies:

Pattern 4: Testing Strategy

Comprehensive testing approach ensuring code quality and reliability.

Testing layers:

Integration Strategies

Integration with CI/CD

Seamless integration into continuous integration and deployment pipelines.

Steps:

  1. Configure pipeline
  2. Set up automation
  3. Define quality gates
  4. Monitor execution

Integration with Development Tools

Connect with popular development tools and IDEs for improved workflow.

Tools:

Integration with Monitoring

Implement monitoring and observability for production systems.

Monitoring aspects:

Team Practices

Establishing Standards

Create and maintain consistent standards across the team.

Standards to define:

Onboarding Process

Streamline onboarding for new team members.

Onboarding steps:

Code Review Guidelines

Effective code review practices for quality assurance.

Review checklist:

Troubleshooting Guide

Common Issue 1

Detailed troubleshooting steps for frequently encountered problem.

Resolution steps:

  1. Identify symptoms
  2. Check configuration
  3. Verify dependencies
  4. Test solution

Common Issue 2

Another common issue with comprehensive resolution approach.

Diagnostic steps:

  1. Reproduce issue
  2. Gather logs
  3. Analyze data
  4. Apply fix

Common Issue 3

Third common scenario with clear resolution path.

Investigation process:

  1. Understand context
  2. Review recent changes
  3. Test hypotheses
  4. Implement solution
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.