Complete guide for developers and AI agents on Cypress E2E testing
- Node.js >= 18
- OpenShift cluster with kubeconfig
- Environment variables configured
cd web/cypress
source ./configure-env.sh # Interactive configuration
npm install # Install dependencies
npm run cypress:open # Start testingFor detailed setup instructions and environment configuration, see README.md
The Monitoring Plugin uses a 3-layer architecture for test organization:
┌─────────────────────────────────────────────────┐
│ Layer 3: E2E Test Files │
│ (cypress/e2e/) │
│ - Call support scenarios │
│ - Specify perspective (Administrator, etc.) │
└────────────────┬────────────────────────────────┘
│ imports
┌────────────────▼────────────────────────────────┐
│ Layer 2: Support Scenarios │
│ (cypress/support/monitoring or perses │
│ - Reusable test scenarios │
│ - Work across multiple perspectives │
│ - Export functions with perspective parameter │
└────────────────┬────────────────────────────────┘
│ uses
┌────────────────▼────────────────────────────────┐
│ Layer 1: Page Object Views │
│ (cypress/views/) │
│ - Reusable UI actions │
│ - Navigation, clicks, assertions │
│ - Use data-test attributes │
└─────────────────────────────────────────────────┘
cypress/
├── e2e/
│ ├── monitoring/ # Core monitoring tests (Administrator)
│ │ ├── 00.bvt_admin.cy.ts
│ │ └── regression/
│ ├── coo/ # COO-specific tests
│ │ ├── 01.coo_bvt.cy.ts
│ │ └── 02.acm_alerting_ui.cy.ts
│ └── virtualization/ # Integration tests (Virtualization)
├── support/
│ ├── monitoring/ # Reusable test scenarios
│ │ ├── 01.reg_alerts.cy.ts
│ │ ├── 02.reg_metrics.cy.ts
│ │ └── 03.reg_legacy_dashboards.cy.ts
│ ├── perses/ # COO/Perses scenarios
│ └── commands/ # Custom Cypress commands
└── views/ # Page object models (reusable actions)
Benefits:
- Test scenarios reusable across Administrator, Virtualization, and Fleet Management perspectives
- Page actions separated from test logic for better maintainability
- UI changes only require updating views, not individual tests
-
Layer 1 - Views: Check/add page actions in
cypress/views/- Under
views/folder, find pre-defined actions per page - If none fits your needs, add new ones
- Under
-
Layer 2 - Support: Add test scenarios to
cypress/support/monitoring/- Add test scenarios to cypress files under
support/folder - Make scenarios reusable across perspectives (Administrator, Virtualization, Fleet Management)
- If it is not applicable, in some cases for Incidents or Fleet Management, test scenarios will be written directly into Layer 3
- Add test scenarios to cypress files under
-
Layer 3 - E2E: Verify e2e files call your scenario (usually pre-configured)
- Administrator:
e2e/monitoring/ - Virtualization:
e2e/virtualization/ - Fleet Management:
e2e/coo/(for ACM)
- Administrator:
// In support/monitoring/01.reg_alerts.cy.ts
import { nav } from '../../views/nav';
import { silencesListPage } from '../../views/silences-list-page';
export const runAlertTests = (perspective: string) => {
describe(`${perspective} perspective - Alerting > Alerts page`, () => {
it('should filter alerts by severity', () => {
// Use page object actions from views/
silencesListPage.filter.byName('test-alert');
silencesListPage.rows.shouldBe('test-alert', 'Active');
});
});
};| Scenario | Action |
|---|---|
| New UI feature | Create new test scenario in support/ |
| Bug fix | Add test case to existing support file |
| Component update | Update existing test scenarios |
| New Perses feature | Create new test scenario in support/ |
| ACM integration | Add test in e2e/coo/ |
- Use Page Objects: Import actions from
cypress/views/ - Data Test Attributes: Prefer
data-testover CSS selectors - Keep Tests Isolated: Each test should run independently
- Meaningful Assertions: Use descriptive error messages
- Document Changes: Update
E2E_TEST_SCENARIOS.md
cd web/cypress
# Run all regression tests
npm run cypress:run -- --spec "cypress/e2e/**/regression/**"
# Run specific feature regression
npm run cypress:run -- --spec "cypress/e2e/monitoring/regression/01.reg_alerts_admin.cy.ts"
npm run cypress:run -- --spec "cypress/e2e/monitoring/regression/02.reg_metrics_admin.cy.ts"
npm run cypress:run -- --spec "cypress/e2e/monitoring/regression/03.reg_legacy_dashboards_admin.cy.ts"
# Run BVT (Build Verification Tests)
npm run cypress:run -- --spec "cypress/e2e/monitoring/00.bvt_admin.cy.ts"
# Run COO tests
npm run cypress:run -- --spec "cypress/e2e/coo/01.coo_bvt.cy.ts"
# Run ACM Alerting tests
npm run cypress:run -- --spec "cypress/e2e/coo/02.acm_alerting_ui.cy.ts"
# Interactive mode (GUI)
npm run cypress:openInteractive (Recommended):
cd web/cypress
source ./configure-env.shManual Setup: For complete environment variable reference and configuration examples, see README.md
| Change Type | Required Tests |
|---|---|
| UI Component Change | Feature-specific regression + BVT |
| API Integration Change | Full regression suite |
| Console Extension Change | BVT + Navigation tests |
| Bug Fix | New test + Related regression |
-
make lint-frontend(no errors) -
make lint-backend(no errors) - Ran BVT tests locally (all passing)
- Ran regression tests for affected features (all passing)
- Created/updated tests for new features or bug fixes
- Updated
E2E_TEST_SCENARIOS.mdif added new tests
- Check test videos:
web/cypress/videos/ - Check screenshots:
web/cypress/screenshots/ - Run with debug:
export CYPRESS_DEBUG=true npm run cypress:run - Run interactively:
npm run cypress:open
| Issue | Solution |
|---|---|
| Test fails intermittently | Check for timing issues, add proper waits |
| Element not found | Verify data-test attributes exist, check page object |
| Assertion fails | Review expected vs actual values, update test |
| Test hangs | Check for infinite loops or missing assertions |
For environment variable issues, login problems, kubeconfig errors, and installation troubleshooting, see README.md
Cypress tests run automatically in the CI pipeline:
- Pre-merge: BVT tests run on every PR
- Post-merge: Full regression suite runs on main branch
- Konflux Pipeline: Automated testing for release candidates
- Cypress Documentation: https://docs.cypress.io/
- Test Scenarios Catalog:
E2E_TEST_SCENARIOS.md - Setup Instructions:
README.md - Main Guide:
../../AGENTS.md