How kkb18/playwright-automation-framework works
Main Components
• Automation Test Runner & Framework Configuration: This includes the configuration files—cucumber.js, playwright.config.ts, package.json, and tsconfig.json.
• Feature Files: Located in src/test/feature, these rich text files written in Gherkin syntax specify the test scenarios.
• Step Definitions: Found in src/test/steps, these files implement the test steps as defined in the feature files.
• Page Objects: In src/test/pages (and also in src/test/pactumJS/pages), these files encapsulate interactions with UI components.
• Helper Modules:
• Hooks (src/test/helper/hooks): Set up and tear down routines to be executed before/after test scenarios.
• Browser Management (src/test/helper/browser): Contains modules to deal with browser setup, context, and page lifecycle.
• Environment Variables (src/test/helper/env): Stores different environment configurations (.env files) and TypeScript definitions.
• Report & Logger (src/test/helper/report and src/test/helper/logger): Manages test execution reports and logging mechanisms.
• Test Data & Parameters (src/test/helper/testData and src/test/helper/parameters): Supplies user and system data; dynamic variable resolution.
• Attachments: For storing any attachments like documents, images, or PDFs relevant to test steps.
• Optional Components:
• PactumJS integration (under src/test/pactumJS): Contains pages, steps, and scripts (e.g., sasTokem.ps1) that might be used for API testing or extended UI testing scenarios.
Relationships and Interactions
• The Test Runner will coordinate running the feature files through Cucumber, using the configurations defined in cucumber.js.
• Feature Files (BDD specifications) drive execution by linking to relevant Step Definitions.
• Step Definitions leverage the Page Objects to perform actions on the web UI via Playwright.
• Helper modules such as hooks, browser management, and environment configurations are called during test setup and execution to manage browser sessions, configure environments, and capture logs/reports.
• CI/CD integration (as evident from GitHub Actions workflows in .github/workflows) ensures that tests are automatically run, with results published into the test-results folder.
• Report generation and logging are handled internally by dedicated modules to provide traceability and evidence of tests run.
Architectural Patterns & Key Design Principles
• Separation of Concerns: The framework cleanly divides BDD specifications, step implementations, page interactions, and utility functionalities.
• Modular Design: Helper modules (for browser, environment, logging, etc.) are organized in separate directories, making the framework extensible and maintainable.
• Reusability: The Page Object Model and step definition structure encourage reusing test logic across multiple feature files.
• CI/CD and Parallel Execution: The configuration and reporting modules support integration with CI/CD pipelines, emphasizing robustness and scalability.