# robbyrob81/cucumber-puppeteer architecture

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

- Interactive diagram: https://gitdiagram.com/robbyrob81/cucumber-puppeteer
- Repository: https://github.com/robbyrob81/cucumber-puppeteer

## Overview

The project is a Behavior-Driven Development (BDD) testing framework that integrates Cucumber (for writing human-readable test scenarios using Gherkin syntax) with Puppeteer (for headless browser automation). It is designed to allow both technical and non-technical stakeholders to collaborate by writing test cases that validate user experiences.

- Test Specification Layer (BDD Features): Represent the .feature files (e.g., callDetails.feature, calls.feature, userLogin.feature) as the entry point where test cases are written in natural language.
- Step Definitions: Include the step definitions folder (features/step_definitions/page_steps.js) indicating how written Gherkin steps are mapped to automation code.
- Support Utilities: Group the files under features/support (actions.js, constants.js, device.js, locale.js, location.js, pages.js, scope.js, url.js) that handle common functionality, configuration settings, and test actions.
- Selectors: Add another component for DOM element selectors (located in features/selectors) which abstract out the element identification needed during browser automation.
- Reporting: Include the reports directory (with report.html and report.json) to indicate that after test execution, results are generated and output in structured format.
- Configuration and Package Management: Represent files like package.json, package-lock.json (or yarn-error.log) to denote dependency management, configuration, and project setup.

##### Relationships and Data Flow
- That Step Definitions invoke the Support Utilities and Selectors, which in turn interact directly with the Puppeteer API to control the headless Chrome browser.
- CI/CD integration touchpoint (if applicable) by connecting from test execution to the Deployment/CI pipeline (even if this component is not explicitly in the file tree, it is referenced in the README).

##### Architectural Patterns and Design Principles
- Modular Architecture: Clearly separate the responsibilities into distinct modules (features, step definitions, support functions, and selectors).
- Abstraction: Note that the selectors and support utilities abstract away low-level Puppeteer interactions, making test steps easy to read and maintain.
- Reusability: Emphasize how common actions and page element selectors are reused across different feature files.
- Clear Separation of Concerns: Demonstrate how the BDD layer (Cucumber features) is decoupled from the automation logic (Puppeteer through step definitions and support).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Package Management
    subgraph "Configuration & Package Management"
      Cfg1("package.json") 
      Cfg2("package-lock.json") 
      Cfg3("yarn-error.log")
    end

    %% Test Specification Layer (BDD Features)
    subgraph "Test Specification Layer (BDD Features)"
      A1("callDetails.feature")
      A2("calls.feature")
      A3("userLogin.feature")
    end

    %% Step Definitions
    subgraph "Step Definitions"
      B1("page_steps.js")
    end

    %% Support Utilities and Selectors (kept as separate nodes)
    S1("Support Utilities")
    S2("Selectors")

    %% Puppeteer Integration
    P1("Puppeteer Integration")

    %% Reporting
    R1("Reporting")

    %% CI/CD Pipeline
    CI("CI/CD Pipeline")

    %% Connections
    %% Configuration files used by Step Definitions
    Cfg1 --> B1
    Cfg2 --> B1
    Cfg3 --> B1

    %% Feature Files feed into Step Definitions
    A1 --> B1
    A2 --> B1
    A3 --> B1

    %% Step Definitions invoke Support Utilities and Selectors
    B1 --> S1
    B1 --> S2

    %% Support Utilities and Selectors use Puppeteer for browser automation
    S1 --> P1
    S2 --> P1

    %% Puppeteer Integration execution returns results to Reporting
    P1 --> R1

    %% Reporting outputs feed into CI/CD Pipeline
    R1 --> CI

    %% Click Events for Component Mapping
    click A1 "https://github.com/robbyrob81/cucumber-puppeteer/blob/master/features/callDetails.feature"
    click A2 "https://github.com/robbyrob81/cucumber-puppeteer/blob/master/features/calls.feature"
    click A3 "https://github.com/robbyrob81/cucumber-puppeteer/blob/master/features/userLogin.feature"
    click B1 "https://github.com/robbyrob81/cucumber-puppeteer/blob/master/features/step_definitions/page_steps.js"
    click S1 "https://github.com/robbyrob81/cucumber-puppeteer/tree/master/features/support"
    click S2 "https://github.com/robbyrob81/cucumber-puppeteer/tree/master/features/selectors"
    click R1 "https://github.com/robbyrob81/cucumber-puppeteer/tree/master/reports"
    click Cfg1 "https://github.com/robbyrob81/cucumber-puppeteer/blob/master/package.json"
    click Cfg2 "https://github.com/robbyrob81/cucumber-puppeteer/blob/master/package-lock.json"
    click Cfg3 "https://github.com/robbyrob81/cucumber-puppeteer/blob/master/yarn-error.log"

    %% Styles
    classDef testSpec fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef stepDef fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef support fill:#FFA07A,stroke:#000,stroke-width:1px;
    classDef selectors fill:#9370DB,stroke:#000,stroke-width:1px;
    classDef puppeteer fill:#D3D3D3,stroke:#000,stroke-width:1px;
    classDef reporting fill:#FFFFE0,stroke:#000,stroke-width:1px;
    classDef cicd fill:#F5DEB3,stroke:#000,stroke-width:1px;
    classDef config fill:#FFC0CB,stroke:#000,stroke-width:1px;

    %% Assign Classes
    class A1,A2,A3 testSpec;
    class B1 stepDef;
    class S1 support;
    class S2 selectors;
    class P1 puppeteer;
    class R1 reporting;
    class CI cicd;
    class Cfg1,Cfg2,Cfg3 config;
```
