Web automation testing example using Cypress for the Project for Testing demo application.
- Node.js 24+
- npm
Clone the repository and install the dependencies:
git clone https://github.com/imranwijaya/cypress-testing-example.git
cd cypress-testing-example
npm installCreate a local .env file based on .env.example:
cp .env.example .envConfigure the required Cypress environment variables:
CYPRESS_BASE_URL="https://example.com/admin"
CYPRESS_LOGIN_NAME="your-login-name"
CYPRESS_LOGIN_EMAIL="your-email@example.com"
CYPRESS_LOGIN_PASSWORD="your-password"
CYPRESS_DB_HOST="127.0.0.1"
CYPRESS_DB_NAME="your-database"
CYPRESS_DB_USER="your-database-user"
CYPRESS_DB_PASSWORD="your-database-password"
CYPRESS_DB_PORT=3306The environment configuration is loaded from .env and validated with Zod
before Cypress starts.
Open Cypress interactively:
npm run cypress:openRun the complete E2E test suite in Chrome:
npm run test:e2eCypress E2E tests run automatically whenever code is pushed to main.
The CI workflow:
- Checks out the repository.
- Runs Cypress on an Ubuntu GitHub-hosted runner.
- Installs and caches project dependencies through the official Cypress GitHub Action.
- Runs the E2E test suite in Chrome.
- Publishes Cypress test results to the GitHub Actions job summary.
- Uploads screenshots when tests fail.
- Uploads videos when tests fail and Cypress produces them.
The following configuration is stored as GitHub Actions Variables:
CYPRESS_BASE_URLCYPRESS_LOGIN_NAMECYPRESS_LOGIN_EMAILCYPRESS_LOGIN_PASSWORD
The following database configuration is stored as GitHub Actions Secrets:
CYPRESS_DB_HOSTCYPRESS_DB_NAMECYPRESS_DB_USERCYPRESS_DB_PASSWORDCYPRESS_DB_PORT
Local development continues to use .env.
GitHub Actions provides the same CYPRESS_* environment variables through
GitHub Variables and Secrets, so the Cypress environment configuration remains
consistent between local development and CI.
Every GitHub Actions run publishes a Cypress test summary containing:
- Passing or failing status
- Total tests
- Passed tests
- Failed tests
- Pending tests
- Skipped tests
- Test duration
When a Cypress test fails, screenshots are uploaded as workflow artifacts.
Video recordings are also uploaded when Cypress produces them.
.
├── cypress/
│ ├── e2e/
│ ├── fixtures/
│ └── support/
├── .github/
│ └── workflows/
│ └── cypress.yml
├── .env.example
├── cypress.config.js
├── env.config.js
├── package.json
└── README.md
This project is licensed under the MIT License.