How jihadrusnanda/learn-playwright works
Main Components
• Test Automation Engine:
• Playwright is the primary tool for browser automation.
• Cucumber is used to define BDD-style feature files (located under src/features) and drive test scenarios based on step definitions (under src/step-definitions).
• Jest covers the unit testing aspects (with tests and reports generated in jest-results/).
• Page Object Model:
• Located under src/pages (with subdirectories for BasePage, LoginPage, etc.), these components abstract actual page interactions.
• These objects interface with Playwright to encapsulate selectors and page behavior.
• Configuration & Support:
• Configuration files (e.g., src/config/Config.ts) and support utilities (src/support/world.ts) provide common and global settings that dictate test behavior.
• Shared selectors defined under src/selectors serve as an abstraction layer for element locations.
• CI/CD & Test Reporting Infrastructure:
• GitHub Actions workflows and reusable actions (under .github/workflows and .github/actions) drive continuous integration testing.
• Scripts (in the scripts folder) provide local debugging and act integration.
• Artifact storage directories for reports (e.g., screenshots, videos, coverage reports, and artifacts).
Relationships and Interactions
• BDD Flow:
• Feature Files (src/features) → Step Definitions (src/step-definitions): Feature files written in Gherkin drive the corresponding steps which in turn invoke methods on Page Objects.
• Page Objects (src/pages) ←→ Playwright: They are the interface for handling browser actions, which are logged and verified through Playwright commands.
• Configuration (src/config) and Support (src/support): Provide global test configurations and world parameters that are accessed by step definitions and page objects.
• CI/CD Integration:
• GitHub Actions triggers test execution (either via unit tests or BDD tests) using Node.js and acts as the orchestration engine.
• Dependency and artifact management steps clearly indicating caching, parallel execution, and artifact uploading.
• Local testing via act (using provided scripts like run-github-workflow.sh and debug scripts under the scripts directory).
Architectural Patterns and Design Principles
• Modular Organization:
• The separation of concerns is evident where features, step definitions, page objects, and configuration are distinct modules.
• Each module has its dedicated folder which helps in isolating testing code from configuration and utility logic.
• Abstraction:
• The Page Object Model abstracts UI interactions.
• Selectors and configuration files promote reuse and consistent access to environment-specific settings.
• CI/CD and Test Automation Optimizations:
• Use of dependency caching, composite actions, and optimized artifact handling make the test framework robust and efficient.
Relevant Technologies, Frameworks, and Dependencies
• TypeScript is used throughout to ensure type safety.
• Playwright for browser automation, with features like video recording and screenshot capture.
• Cucumber for BDD tests, enabling feature-driven development.
• Jest for running unit tests.
• GitHub Actions and act for CI/CD management.
• Additional utilities include dotenv for environment variables and cucumber-html-reporter for generating reports.