How muratkeremozcan/cypress-react-component-test-examples works
Project Type and Purpose
• This is a frontend‐focused repository containing a small React application (built with Create React App and TypeScript) plus a rich suite of Cypress examples (component tests under cypress/component and end-to-end tests under cypress/e2e).
• Purpose: provide working Cypress 10+ examples for both component testing (CT) and e2e testing, along with continuous integration workflows.
Key Directories and Indicators
• src/ : the React application source (App.tsx, index.tsx, CSS, test harness).
• public/ & index.html : static assets served by the development server.
• cypress/ :
• component/ : hundreds of component‐level test examples organized by topic or library.
• e2e/ : end-to-end tests (e.g. sanity checks).
• support/, fixtures/ : Cypress support code and test data.
• .github/workflows/ : CI pipelines (build, lint, type-check, e2e, CT).
• package.json & yarn scripts: orchestrate start, cy:open, cy:run, cy:open-ct, cy:run-ct.
Main Components
A. Developer Workstation
• Node.js & Yarn/NPM
• Local filesystem containing repo
• IDE/editor
B. React Development Server
• Webpack dev server (CRA) serving public/index.html and compiled JS/CSS from src/
C. Cypress Runners
1. E2E Runner
• Spins up against the React Dev Server over HTTP
• Executes cypress/e2e spec files
2. Component Test Runner (CT)
• Bundles mounted React components via a special Webpack config
• Executes cypress/component spec files without full server
D. Continuous Integration (GitHub Actions)
• Checkout & cache node_modules
• Build step (yarn build or tsc)
• Lint & Type-check
• Cypress e2e tests (cy:run)
• Cypress CT tests (cy:run-ct)
E. External Services
• NPM/Yarn Registry for dependency installation
• (Optional) Cypress Dashboard for test reporting badge
Relationships & Data Flows
• Developer triggers Yarn commands → invokes CRA dev server or Cypress CLI
• CRA server serves assets → Browser / E2E runner hits http://localhost:3000
• CT runner mounts individual components → no HTTP server required
• CI triggers actions sequentially → caches dependencies → builds → tests → reports status
Architectural Patterns & Principles
• Clear separation of production app code (src/, public/) vs. test code (cypress/)
• Single‐page application (SPA) served by a dev server
• Two testing layers:
• E2E tests exercise full app through browser API
• Component tests isolate and mount individual React components
• Multi-stage CI for performance: cache → build → lint → type-check → test