Directory Overview
The framework follows a clean, organized structure that separates concerns and promotes maintainability:Configuration Files
UI Configuration
The UI configuration targets web application testing:cypress.config.ui.ts
baseUrl: Base URL for allcy.visit()calls in UI testsspecPattern: Only runs tests in theui/directorywatchForFileChanges: Disabled to prevent auto-reloading during development
API Configuration
The API configuration is optimized for REST API testing:cypress.config.api.ts
baseUrl: Points to the API endpointspecPattern: Only runs tests in theapi/directory
Test Directories
UI Tests (e2e/ui/)
Contains all UI-focused test files:
- LoginPageSpec.cy.ts: Tests for authentication flows
- HomePageSpec.cy.ts: Tests for home page functionality (sorting, filtering)
- CheckoutPageSpec.cy.ts: Tests for checkout process
All UI test files follow the naming convention
*Spec.cy.ts or *.cy.ts. The .cy.ts extension is required for Cypress to recognize test files.API Tests (e2e/api/)
Contains all API test files:
- GETSpec.cy.ts: Tests for GET requests, response validation, and performance
cy.request() command without page objects.
Fixtures Directory
Fixtures store test data as JSON files, providing:- Centralized data management: One place to update test data
- Reusability: Multiple tests can share the same data
- Separation of concerns: Keep test data separate from test logic
Example: Users Fixture
users.json
Example: API Data Fixture
bookings.json
Support Directory
Page Objects (support/pages/)
Page objects encapsulate page-specific logic:
BasePage.ts
BasePage for shared functionality.
Custom Commands (support/commands.ts)
Define reusable Cypress commands for common operations:
Global Setup (support/e2e.ts)
Loads before every test file:
e2e.ts
- Importing custom commands
- Global beforeEach hooks
- Third-party plugin initialization
File Naming Conventions
Test Files
*.cy.ts - Cypress test specification filesPage Objects
PascalCase.ts - Page object class filesFixtures
camelCase.json - Test data fixture filesConfig Files
cypress.config.*.ts - Configuration filesTypeScript Integration
All test files use TypeScript for:- Type safety: Catch errors before runtime
- IntelliSense: Better autocomplete in IDEs
- Refactoring: Safer code modifications
- Documentation: Types serve as inline documentation
Best Practices
- Keep tests in appropriate directories: UI tests in
ui/, API tests inapi/ - Use fixtures for test data: Never hardcode test data in test files
- One page object per page: Each page should have its own class
- Extend BasePage: Inherit common functionality from the base class
- Descriptive file names: Names should indicate what’s being tested
Next Steps
Page Object Model
Learn the POM pattern in detail
Configuration
Deep dive into configuration options
Creating Page Objects
Build your own page objects
Using Fixtures
Master test data management