# alexneo2003/playwright-azure-reporter architecture

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

- Interactive diagram: https://gitdiagram.com/alexneo2003/playwright-azure-reporter
- Repository: https://github.com/alexneo2003/playwright-azure-reporter

## Overview

##### Main Components
- Playwright Test Runner: Although not explicitly part of the package, the integration configuration (via playwright.config.ts) shows how the reporter is plugged into the test execution process.
- Azure Reporter Module: This is the core of the package. In the src directory you have files like logger.ts, playwright-azure-reporter.ts, and utils.ts that likely contain the logic to parse test case IDs, handle logging, and interact with Azure DevOps.
- Test Configuration & Fixtures: Under tests/config and tests/reporter, you find various assets, certificates, and fixture files used for simulating or validating the reporter’s behavior.
- CI/CD Integration: The presence of GitHub workflows (.github/workflows) and Azure configuration (azure.config.json) emphasize continuous integration aspects which, although not directly part of the runtime architecture, are involved in deployment and automated testing.
- External Service: Azure DevOps (and its related endpoints for test plans, test runs, and configurations) act as an external system that receives and processes test results from the reporter.

##### Relationships and Interactions Between Components
- The Playwright Test Runner (configured in playwright.config.ts) triggers test execution. During test execution, the custom reporter (https://npm link '@alex_neo/playwright-azure-reporter') is invoked to capture test result events.
- The Azure Reporter module receives these events, parses test names/annotations to extract test case IDs (using the specified testCaseIdMatcher and testCaseIdZone), and then formats and uploads the result data to Azure DevOps.
- The Logger (src/logger.ts) and Utility functions (src/utils.ts) play supporting roles for error logging, debugging, and data transformation.
- The tests directories simulate both integration and unit testing of the reporter’s functionality – these validate the mapping of test results to their proper Azure test configurations.
- The CI/CD components (GitHub workflows and husky pre-commit hooks) ensure that code quality, tests, and publishing are maintained throughout the development lifecycle.
- The communication between the reporter and Azure DevOps is a key, external interface; this should be represented as an API interaction (HTTP calls to Azure DevOps Test APIs using credentials/tokens from configuration).

##### Architectural Patterns and Design Principles
- Modular Design: Separation between core reporter logic (src) and tests/fixtures. This separation facilitates maintainability and extensibility.
- Configuration-Driven Behavior: The reporter accepts many options (e.g., token, orgUrl, projectName, planId, etc.) and uses patterns to extract test case IDs. This makes it easily configurable and adaptable to different environments and Azure setups.
- Integration Testing Focus: The extensive tests directory indicates that the developer emphasizes verifying correct interaction with Azure and accurate reporting.
- Extensibility via Callbacks: The ability to pass a custom “testPointMapper” callback highlights an extensible design that allows for dynamic mapping of test run results based on differing configurations (e.g., for different browsers).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Pipeline Components
    subgraph "CI/CD Pipeline Components"
        E2["GitHub Workflows"]:::cicd
        E3["Husky Pre-commit Hooks"]:::cicd
    end

    %% Main Execution Flow
    A["Playwright Test Runner"]:::testRunner
    C["Configuration Sources"]:::config
    B["Azure Reporter Module"]:::reporter
    D["Azure DevOps Test API"]:::external

    %% Internal Components of Azure Reporter Module
    subgraph "Azure Reporter Module Internal Components"
        B1["Logger"]:::reporter
        B2["Utility Functions"]:::utility
        B3["Test Case ID Parser"]:::reporter
        B4["Attachment Handler"]:::reporter
        B5["Azure API Communication"]:::reporter
        B6["Custom testPointMapper callback"]:::reporter
    end

    %% Tests & Fixtures Cluster
    subgraph "Tests & Fixtures"
        F["Test Config & Fixtures"]:::test
        G["Reporter Testing & Simulation Assets"]:::test
    end

    %% Connections
    E2 --> A
    E3 --> A
    A --> B
    C --> B
    B --> D
    F --- B
    G --- B

    %% Click Events
    click A "https://github.com/alexneo2003/playwright-azure-reporter/blob/main/playwright.config.ts"
    click B "https://github.com/alexneo2003/playwright-azure-reporter/blob/main/src/playwright-azure-reporter.ts"
    click B1 "https://github.com/alexneo2003/playwright-azure-reporter/blob/main/src/logger.ts"
    click B2 "https://github.com/alexneo2003/playwright-azure-reporter/blob/main/src/utils.ts"
    click F "https://github.com/alexneo2003/playwright-azure-reporter/tree/main/tests/config"
    click G "https://github.com/alexneo2003/playwright-azure-reporter/tree/main/tests/reporter"
    click E2 "https://github.com/alexneo2003/playwright-azure-reporter/tree/main/.github/workflows"
    click E3 "https://github.com/alexneo2003/playwright-azure-reporter/blob/main/.husky"
    click C "https://github.com/alexneo2003/playwright-azure-reporter/blob/main/azure.config.json"

    %% Styles
    classDef testRunner fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef reporter fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef utility fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef config fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef external fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef cicd fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef test fill:#E0FFFF,stroke:#000,stroke-width:2px;
```
