# vasu31dev/playwright-ts architecture

> Architecture diagram of the GitHub repository vasu31dev/playwright-ts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vasu31dev/playwright-ts
- Repository: https://github.com/vasu31dev/playwright-ts

## Overview

##### Project Type & Purpose
- This project is an automation testing framework built using Playwright and TypeScript. Its purpose is to simplify automated testing of web (desktop and mobile), APIs, and Electron applications by implementing a unique Page Object Model (POM) pattern, complete with utilities for common actions and assertions.
- It caters to QA professionals, developers, and even business analysts by abstracting many complexities of test setup and execution. The framework also boasts built-in support for CI/CD (e.g., GitHub Actions) and advanced reporting.

##### Key Components
a. Configuration & Setup:
- Files such as “playwright.config.ts”, “tsconfig.json”, and configuration files for ESLint, Prettier, and Husky indicate that there is a robust local and CI/CD configuration.
- The “src/vasu-playwright/setup” directory includes modules like global-setup.ts, global-teardown.ts, custom-logger.ts, page-setup.ts, and optional parameter types that are central to initializing and managing the test environment.

b. Core Framework Logic:
- “src/vasu-playwright/utils” contains various utility modules (action-utils, assert-utils, element-utils, locator-utils, page-utils, and timeout-constants) that abstract and simplify Playwright calls. This layer encapsulates the common actions, assertions, and locator strategies used across tests.

c. Testing Modules & Page Object Models (POM):
- The “tests” directory is neatly divided into “pages” and “specs.” Within “tests/pages”, there are two distinct POM strategies (“preferred-pom” and “traditional-pom”). Each set of page objects (e.g., sauce-demo-login-page, sauce-demo-mini-cart, and sauce-demo-products-page) encapsulate UI logic and actions.
- The “tests/specs” directory holds the actual test scripts that import these page objects and run tests. This separation reinforces modularity and reusability.

d. Documentation & CI/CD Integration:
- The “docs” directory includes detailed guides on installation, testing practices, framework setup, and comparisons of POM designs. It also provides usage instructions for developers.
- Files like .husky (and its scripts) indicate Git hooks are used to enforce quality standards before code commits. GitHub Action integration (as mentioned in the README) provides CI/CD support.

##### Relationships and Data Flow
- Tests (specs) rely on the page objects located under “tests/pages” which in turn use the utilities and setup provided by “src/vasu-playwright”.
- The “PageSetup” module establishes the page state before tests run. Functions from “src/vasu-playwright/setup/page-setup.ts” and “src/vasu-playwright/utils/page-utils.ts” ensure that each test works with a consistent page instance.
- Utility modules act as shared components for executing actions and performing assertions across both types of POM implementations.
- CI/CD components (e.g., pre-commit hooks via Husky) integrate with version control to ensure quality and can be mapped to automated test execution on pull requests.

##### Architectural Patterns & Technologies
- The project employs a modular architecture with clear separation of concerns: one module for configuration and initialization, one for utility functions, and separate modules for test definitions and page logic.
- It uses an enhanced/unique Page Object Model pattern that reduces complexity compared to traditional POM.
- The framework builds on Playwright’s testing libraries and makes extensive use of TypeScript for type safety.
- It leverages additional libraries/tools such as ESLint, Prettier, Winston logger (custom-logger.ts), and Git hooks (Husky) to ensure code quality and reliability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Setup Layer
    subgraph "Configuration & Setup"
        A1["Playwright Config"]:::config
        A2["TS Config"]:::config
        A3["ESLint Config"]:::config
        A4["Prettier Config"]:::config
        A5["Husky Pre-commit Hook"]:::config
        A6["Setup Modules"]:::setup
    end

    %% Core Utility Layer
    subgraph "Core Utilities"
        B1["Utility Modules"]:::utility
    end

    %% Page Object Models Layer
    subgraph "Page Object Models"
        C1["Preferred POM"]:::pom
        C2["Traditional POM"]:::pom
    end

    %% Test Specifications Layer
    subgraph "Test Specifications"
        D1["Test Specs"]:::test
    end

    %% CI/CD & Documentation Layer
    subgraph "CI/CD & Documentation"
        E1["Documentation"]:::docs
        E2["CI/CD Integration"]:::cicd
    end

    %% Relationships
    %% Configuration files feed Setup Modules
    A1 -->|"feeds"| A6
    A2 -->|"feeds"| A6
    A3 -->|"feeds"| A6
    A4 -->|"feeds"| A6
    A5 -->|"feeds"| A6

    %% Setup Modules initialize Page Object Models
    A6 -->|"initializes"| C1
    A6 -->|"initializes"| C2

    %% Utility Modules support Page Object Models
    B1 -->|"supports"| C1
    B1 -->|"supports"| C2

    %% Page Object Models are used by Test Specs
    C1 -->|"usedBy"| D1
    C2 -->|"usedBy"| D1

    %% CI/CD Integration triggers Test Specs
    E2 -->|"triggers"| D1

    %% Documentation guides Test Specs
    E1 -->|"guides"| D1

    %% Styles
    classDef config fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef setup fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef utility fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef pom fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef test fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef cicd fill:#D8BFD8,stroke:#000,stroke-width:2px;
    classDef docs fill:#D8BFD8,stroke:#000,stroke-width:2px;

    %% Click Events
    click A1 "https://github.com/vasu31dev/playwright-ts/blob/main/playwright.config.ts"
    click A2 "https://github.com/vasu31dev/playwright-ts/blob/main/tsconfig.json"
    click A3 "https://github.com/vasu31dev/playwright-ts/blob/main/.eslintrc"
    click A4 "https://github.com/vasu31dev/playwright-ts/blob/main/.prettierrc"
    click A5 "https://github.com/vasu31dev/playwright-ts/tree/main/.husky/pre-commit"
    click A6 "https://github.com/vasu31dev/playwright-ts/tree/main/src/vasu-playwright/setup/"
    click B1 "https://github.com/vasu31dev/playwright-ts/tree/main/src/vasu-playwright/utils/"
    click C1 "https://github.com/vasu31dev/playwright-ts/tree/main/tests/pages/preferred-pom/"
    click C2 "https://github.com/vasu31dev/playwright-ts/tree/main/tests/pages/traditional-pom/"
    click D1 "https://github.com/vasu31dev/playwright-ts/tree/main/tests/specs/"
    click E1 "https://github.com/vasu31dev/playwright-ts/tree/main/docs/"
    click E2 "https://github.com/vasu31dev/playwright-ts/blob/main/.husky"
```
