How mehmetgul/playwright-template-framework works
Main Components
• Test Runner & Framework: Central to the design is the Playwright test runner (as configured in playwright.config.ts) that orchestrates the execution of tests. Indicate that Playwright is the core technology used.
• Page Object Model (POM): In the src/pageObjects directory, there are modules for different pages such as HomePage, CartPage, and ProductPage. Represent these as separate components/classes that encapsulate UI interactions.
• API Layer: The src/api directory, containing files like UserAPI.ts, represents the API testing functionality. This component should be linked to tests that call API endpoints.
• Fixtures and Data: The src/fixtures directory (including custom fixtures and test-data JSON) shows the framework’s support for dynamic test setup and data management. These can be represented as “Test Fixtures” that feed data into tests.
• Configuration & Environment Management: The config directory holds environment-specific JSON configuration files (dev.json, prod.json, qa.json, uat.json). These should connect to a “Configuration Manager” component (represented via utils/config-loader.ts and utils/environment.ts) that dynamically sets up test parameters.
• Cleanup & Reporting: Introduce components for automated artifact cleanup (cleanup.ts script) and reporting mechanisms. The README also mentions Allure and Playwright HTML report generation (with specific commands and possibly a dedicated “artifacts” directory). Represent these as reporting and artifact management modules.
Relationships and Data Flow
• The Test Runner (Playwright) orchestrates test execution, calling the appropriate test files (e.g., tests/ui/ecommerce.spec.ts).
• Some tests also trigger API calls that route through the API layer (UserAPI.ts). Show bi-directional interactions if needed (e.g., for data validation or setup/teardown).
• The Configuration Manager loads environment variables from the config folder and feeds them into the tests and utilities.
• Utility modules (Logger, File Utils, Test Data Generator) support both Page Objects and API calls, and influence reporting results (e.g., log outputs connect to reports).
• Post-test execution, the Cleanup module is triggered to clear artifacts before/running tests, ensuring a clean state. Indicate data flow back to the test runner.
Architectural Patterns & Technologies
• The Page Object Model (POM) is explicitly used for UI abstraction.
• Separation of concerns is achieved by keeping tests, fixtures, page objects, API testing, and utilities in distinct directories.
• Environment-based configuration (via JSON files and config-loader) makes the framework highly adaptable.
• The framework is modular and supports advanced reporting using Allure and Playwright’s built-in HTML reporting.