Cypress β Simple CRUD Test AutomationΒΆ
A test automation project built with Cypress for a Simple CRUD web app, featuring UI E2E tests, API specs, visual testing with Applitools, and HTML reporting auto-published to GitHub Pages.
π FeaturesΒΆ
Core CapabilitiesΒΆ
- UI E2E Testing: Cypress browser automation for Simple CRUD flows
- API Testing: Specs under
cypress/e2e/simple-crud/api/ - Environment Switching:
--env version=development|productionvia JSON config - HTML Reporting: Mochawesome-based report aggregated into a single HTML file
Advanced FeaturesΒΆ
- Parallel Execution:
cypress-parallelfor folder-based parallel runs - Visual Testing:
@applitools/eyes-cypresssample specs - Config-as-Code: environment JSON is applied dynamically in
cypress.config.js - POM Helpers: reusable helpers under
cypress/pom/ - GitHub Pages Hosting: CI builds and deploys the latest report to GitHub Pages
π Framework MetricsΒΆ
- Language: JavaScript (CommonJS)
- Test Runner: Cypress (
^15.12.0) - Parallel Runner:
cypress-parallel(^0.15.0) - Visual Testing: Applitools Eyes (
@applitools/eyes-cypress) - CI/CD: GitHub Actions (Node 20)
π Project StructureΒΆ
cypress-basic/
βββ .github/
β βββ workflows/
β βββ cypress-cloud-tests.yml # CI: run E2E suite + build + deploy report
βββ cypress/
β βββ e2e/
β β βββ simple-crud/
β β β βββ api/ # API-focused specs
β β β βββ ui/ # UI E2E specs (incl. POM-based tests)
β β βββ visual-testing/ # Applitools sample specs
β β βββ xample/ # Cypress example specs (learning/reference)
β βββ environment/
β β βββ development.json # Local config (default)
β β βββ production.json # Production config
β βββ fixtures/ # Test data
β βββ pom/ # Helpers (page objects / API helpers)
β βββ reports/ # Generated mochawesome HTML report (index.html)*
β βββ support/ # Commands + support setup
βββ cypress.config.js # Loads environment JSON based on --env version=...
βββ package.json
βββ README.md
*cypress/reports/ is generated by the reporting scripts and in CI before it is uploaded/deployed.
ποΈ Directory OverviewΒΆ
| Directory / File | Purpose |
|---|---|
.github/workflows/ |
CI pipeline: install deps, run Cypress, upload failure artifacts |
cypress/e2e/simple-crud/ui/ |
UI E2E specs for the CRUD app |
cypress/e2e/simple-crud/api/ |
API specs for CRUD endpoints/flows |
cypress/e2e/visual-testing/ |
Visual testing examples using Applitools |
cypress/environment/ |
Environment JSON config files (baseUrl, timeouts, video, etc.) |
cypress/pom/ |
Shared helpers used by specs (POM / API helper modules) |
cypress/support/ |
Global Cypress support config + custom commands |
cypress.config.js |
Applies environment config at runtime based on config.env.version |
π οΈ Technologies & DependenciesΒΆ
Core TechnologiesΒΆ
- Cypress: end-to-end test runner
- dotenv: local environment variable loading
- cypress-parallel: parallel execution across specs/folders
- @applitools/eyes-cypress: visual testing integration
Reporting & Utilities (devDependencies)ΒΆ
- mochawesome: JSON/HTML reporter for Cypress/Mocha
- mochawesome-merge: merge multiple mochawesome JSON files
- mochawesome-report-generator: generate final HTML report
- rimraf: clean
cypress/reportsbefore regenerating
npm ScriptsΒΆ
| Script | Command | Purpose |
|---|---|---|
npm test |
cypress open |
Interactive runner (choose specs in UI) |
npm run test:prod:headless |
cypress run --env version=production |
Headless run against production config |
npm run cy:e2e |
cypress run --spec 'cypress/e2e/simple-crud/**/*.cy.js' --env version=production |
Run Simple CRUD suite (prod) |
npm run cy:api |
cypress-parallel -d cypress/e2e/simple-crud/api/ -s test:prod:headless |
Run API specs in parallel (prod) |
npm run cy:full-e2e |
cypress-parallel -d cypress/e2e/simple-crud/ -t 6 -s test:prod:headless |
Run full Simple CRUD folder in parallel (prod) |
npm run report:clean |
rimraf cypress/reports |
Remove existing report output |
npm run report:merge |
mochawesome-merge "cypress/reports/json/*.json" -o cypress/reports/result.json |
Merge mochawesome JSON files |
npm run report:generate |
marge cypress/reports/result.json --reportDir cypress/reports --reportFilename index --inline |
Build HTML report as cypress/reports/index.html |
npm run test-e2e:report |
composite | Clean β run E2E β merge β generate HTML in one command |
π¦ Getting StartedΒΆ
PrerequisitesΒΆ
- Node.js 20+ (matches CI)
- npm
InstallationΒΆ
βΆοΈ Running TestsΒΆ
Headless run (production)ΒΆ
Run the Simple CRUD suite (production)ΒΆ
π Environment ConfigurationΒΆ
This repo loads environment config from JSON:
- development β
cypress/environment/development.json(default if not provided) - production β
cypress/environment/production.json
How it works:
- cypress.config.js reads config.env.version || 'development'
- then loads ./cypress/environment/<version>.json
- and applies values like baseUrl, defaultCommandTimeout, video, etc.
Example (force development):
π Visual Testing (Applitools)ΒΆ
Visual testing specs live under cypress/e2e/visual-testing/.
- Required: set
APPLITOOLS_API_KEYin your environment - Recommended: keep secrets out of git (donβt commit real keys)
π CI/CD PipelineΒΆ
GitHub Actions WorkflowΒΆ
Workflow file: cypress-cloud-tests.yml
- Runs on push to
main/Master - Uses Node.js 20 +
npm ci - Executes
npm run cy:e2eviacypress-io/github-action@v6 - Always runs reporting steps (even if tests fail):
npm run report:mergenpm run report:generate- Uploads
cypress/reports/as an artifact (cypress-report)
GitHub Pages β Report HostingΒΆ
The pipeline is configured to publish the generated report to GitHub Pages:
actions/upload-pages-artifact@v3uploadscypress/reports/as the Pages artifactactions/deploy-pages@v4deploys it to thegithub-pagesenvironment- The deployed site serves
cypress/reports/index.htmlas the landing page
After enabling GitHub Pages for the repository (Source: GitHub Actions), your live report URL will be:
π TroubleshootingΒΆ
Tests fail locally with baseUrl / connection errorsΒΆ
- If youβre running locally, use
--env version=developmentand ensure the app is running at thebaseUrlfromcypress/environment/development.json.
Environment file not being appliedΒΆ
- Ensure you pass
--env version=production(ordevelopment) exactly. - Check
cypress.config.jsfor theconfig.env.versionlogic.
Applitools tests failingΒΆ
- Verify
APPLITOOLS_API_KEYis set in your shell environment before running tests.
π€ ContributingΒΆ
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "Add your feature" - Push the branch:
git push origin feature/your-feature - Open a Pull Request
Development GuidelinesΒΆ
- Keep specs organized under the relevant area (
simple-crud/api,simple-crud/ui,visual-testing) - Prefer reusing shared helpers under
cypress/pom/ - Update this README when scripts, structure, or environment handling changes
π Quick LinksΒΆ
- Cypress Docs:
https://docs.cypress.io - Applitools Eyes Cypress Docs:
https://applitools.com/docs/api-ref/sdk-api/cypress/ - Simple CRUD App (production target):
https://simple-crud-apps.vercel.app - Cypress Test Result Liver Report:
https://fahmi-wiradika.github.io/cypress-basic - Project Documentation:
https://fahmi-wiradika.github.io/projects/professional/frameworks/cypress/
π LicenseΒΆ
ISC (see package.json)