How rgenes28/ecom-automation works
Project Type and Purpose
• This is a QA automation framework built with Playwright and TypeScript.
• Its goal is to automate end-to-end (E2E) tests against an e-commerce application using the Page Object Model (POM), custom API clients, and utility modules.
• Tests are orchestrated locally and in CI via GitHub Actions.
File Structure Analysis
• Top-level configuration
• .env, .dev.env, .prod.env, env.config.ts: environment variables and runtime config
• playwright.config.ts: Playwright Test runner settings
• .github/workflows/playwright-tests.yml: CI pipeline definition
• Core framework layers
• pages/: POM classes (HomePage, LoginPage, RegisterPage, CheckoutPage, etc.)
• api-clients/: wrappers for REST calls (order.api-client.ts, user.api-client.ts)
• utils/: shared helpers (apiEcomus.ts, data generation, logging)
• data/: test data definitions (testdata.ts)
• Test suites
• tests/: canonical E2E test specs (login, home, register, checkout, e2e)
• tests-examples/: demo or scratch specs (demo-todo-app.spec.ts)
• Artifacts
• screenshots/: captures from failed or validated tests
• Dependency files
• package.json / package-lock.json
Architectural Patterns
• Page Object Model (separation of test logic and UI interaction)
• Layered design
1. Test Runner (Playwright Test)
2. Test Specs (tests/)
3. Domain Models (pages/, api-clients/, utils/)
• Environment-driven configuration for different targets (dev, prod, CI)
Main Components & Interactions
a. Playwright Test Runner
• Reads playwright.config.ts and env.config.ts
• Spawns browser contexts and test workers
• Orchestrates lifecycle hooks (beforeAll, afterEach, etc.)
b. Test Specs (tests/, tests-examples/)
• Scenarios using POM and API clients
• Import page objects, utils, test data
c. Page Objects (pages/)
• Expose methods to interact with UI (click, type, expect)
• Encapsulate locators and selectors
d. API Clients (api-clients/)
• Provide direct REST access for setup/teardown or bypass UI
e. Utilities (utils/, data/)
• Data providers, random-data generation, custom assertions
f. Configuration Layer
• .env files, env.config.ts control baseURLs, credentials
g. CI/CD (GitHub Actions)
• Triggers on push or PR
• Installs dependencies, runs Playwright tests, uploads artifacts (screenshots, traces)