This repository demonstrates how to set up and run end-to-end tests using Cypress, integrated with a CI/CD pipeline for automated testing. The project is configured to run tests through GitHub Actions, making it easy to execute and publish results automatically.
- End-to-End Testing: Using Cypress to test web applications.
- CI/CD Integration: Run tests on GitHub Actions or Google Cloud Build.
- Test Filtering: Filter tests by tags to run specific test categories.
- Automated Reporting: Test results published to GitHub Pages.
- Cross-browser Testing: Supports testing on different browsers via Cypress.
- Configuration: Configurable for different environments and use cases.
- Visual Testing: Integrated with Percy and LambdaTest SmartUI for visual regression testing.
To set up this project locally:
- Clone the repository:
git clone https://github.com/bhargav-garlapati/cypress-example-e2e.git
- Install dependencies:
./init.sh
(This shell script will fetch env variables from GCP and install dependencies)
If you encounter access issues, please create a file named cypress.env.json in the root directory of the repository locally, and add the following test secrets:
{
"BASIC_AUTH_USERNAME": "admin",
"BASIC_AUTH_PASSWORD": "admin",
"USERNAME": "tomsmith",
"PASSWORD": "SuperSecretPassword!",
"test": "test"
}
Next, install dependencies npm install
-
Run Tests
npm run cy:production
To run tests with specific tags:
CYPRESS_grepTags="ui,authentication" npm run cy:production
The tests are automatically triggered on every push request, with the results displayed on GitHub Pages.
You can manually trigger tests in GitHub Actions:
- Go to the Actions tab in the repository
- Select "Cypress Tests on GH Actions" workflow
- Click "Run workflow"
- Choose your environment, specs, and tags (optional)
- Click "Run workflow"
You can manually trigger tests in Google Cloud Build through GitHub Actions:
- Go to the Actions tab in the repository
- Select "Cypress Tests on GCP" workflow
- Click "Run workflow"
- Choose your environment, specs, and tags (optional)
- Click "Run workflow"
This will trigger a Cloud Build job that runs the tests and publishes the results.
Tests are organized with tags to allow running specific types of tests. Available tags include:
- ui: User interface tests
- authentication: Login and authentication tests
- form: Form interaction tests
- form-elements: Tests for specific form elements like checkboxes
- accessibility: Accessibility tests using axe-core
- visual-testing: Visual regression tests using Percy
- smartui: Visual tests using LambdaTest SmartUI
- alerts: Tests for JavaScript alerts, confirms, and prompts
- iframe: Tests for iframe interactions
- drag-drop: Tests for drag and drop functionality
- file-operations: Tests for file upload/download
- dom-manipulation: Tests for DOM manipulation
- negative-test: Tests that are expected to fail
- security: Security-related tests
You can run tests with specific tags using:
CYPRESS_grepTags="ui,authentication" npm run cy:productionOr in CI/CD by specifying the tags in the workflow inputs.
- A/B Variation
- Accessibility
- Add and Remove Elements
- Basic Auth Test
- Interacting with Checkboxes
- Drag and Drop Items
- Handling Iframes
- Handling JS Alerts, Confirm, and Prompt
- Login Flow test
- Upload file
- UI Visual Testing using Percy & LambdaTest Smart UI (Applitools Eyes coming soon...)
Each test can be run individually or as part of the complete test suite.
You can view the test execution results here: https://bhargav-garlapati.github.io/cypress-example-e2e/
Percy.io visual regression results:
License: This project is licensed under the MIT License. See the LICENSE file for details.