# artesgo/playwright-harness architecture

> Architecture diagram of the GitHub repository artesgo/playwright-harness, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/artesgo/playwright-harness
- Repository: https://github.com/artesgo/playwright-harness
- Video tour (about a minute): https://gitdiagram.com/artesgo/playwright-harness/video

## Overview

playwright-harness is a browser-based, framework-agnostic tool for recording app interactions and turning them into Playwright tests. The main workflow is: a user opens the harness, interacts with the proxied app to record steps, optionally replays or edits them, then generates test code. Existing specs can also be discovered, loaded into steps, and edited. The core browser features are concentrated in harness.js; record.mjs and steps.mjs provide supporting logic. The README documents capabilities whose implementation details are not shown in the excerpts, so those links rely on that documentation.

Main entry points: [`harness.js`](https://github.com/artesgo/playwright-harness/blob/main/harness.js) (Step editing), [`server.mjs`](https://github.com/artesgo/playwright-harness/blob/main/server.mjs) (HTTP server), [`record.mjs`](https://github.com/artesgo/playwright-harness/blob/main/record.mjs) (Recording helpers), [`specs.mjs`](https://github.com/artesgo/playwright-harness/blob/main/specs.mjs) (Spec discovery)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Harness runtime"]
  node_server["HTTP server<br/>[server.mjs]"]
  node_shell["Harness page<br/>[index.html]"]
  node_client["Harness UI<br/>[harness.js]"]
  node_proxy["App proxy<br/>[server.mjs]"]
  node_iframe["App iframe<br/>[harness.js]"]
  node_specapi["Spec endpoint<br/>[server.mjs]"]
end

subgraph group_authoring["Test authoring"]
  node_recording["Interaction recording<br/>[harness.js]"]
  node_selector["Selector picking<br/>[harness.js]"]
  node_steps["Step editing<br/>[harness.js]"]
  node_replay["Step replay<br/>[harness.js]"]
  node_codegen["Test generation<br/>[harness.js]"]
  node_discovery["Spec discovery<br/>[specs.mjs]"]
  node_loading["Spec loading<br/>[harness.js]"]
end

subgraph group_support["Step support"]
  node_parser["Step parser<br/>[steps.mjs]"]
  node_helpers["Recording helpers<br/>[record.mjs]"]
end

node_user(("Harness user"))
node_app["Running app"]
node_specdir["Test directory"]

node_user -->|"opens"| node_shell
node_server -->|"serves"| node_shell
node_server -->|"routes app requests"| node_proxy
node_proxy -->|"forwards HTTP"| node_app
node_client -->|"inspects"| node_iframe
node_iframe -->|"loads app through"| node_proxy
node_user -->|"records interactions"| node_recording
node_recording -->|"uses"| node_helpers
node_recording -->|"adds steps"| node_steps
node_user -->|"picks elements"| node_selector
node_selector -->|"uses selector helpers"| node_helpers
node_user -->|"edits steps"| node_steps
node_user -->|"starts replay"| node_replay
node_replay -->|"runs actions in"| node_iframe
node_steps -->|"groups waits"| node_helpers
node_steps -->|"generates test"| node_codegen
node_user -->|"configures"| node_specdir
node_server -->|"serves endpoint"| node_specapi
node_specapi -->|"calls"| node_discovery
node_discovery -->|"reads specs"| node_specdir
node_user -->|"loads a test"| node_loading
node_loading -.->|"fetches specs"| node_specapi
node_loading -->|"parses source"| node_parser
node_parser -->|"returns steps"| node_steps

click node_server "https://github.com/artesgo/playwright-harness/blob/main/server.mjs"
click node_shell "https://github.com/artesgo/playwright-harness/blob/main/index.html"
click node_client "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_proxy "https://github.com/artesgo/playwright-harness/blob/main/server.mjs"
click node_iframe "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_recording "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_selector "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_steps "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_replay "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_codegen "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_discovery "https://github.com/artesgo/playwright-harness/blob/main/specs.mjs"
click node_specapi "https://github.com/artesgo/playwright-harness/blob/main/server.mjs"
click node_loading "https://github.com/artesgo/playwright-harness/blob/main/harness.js"
click node_parser "https://github.com/artesgo/playwright-harness/blob/main/steps.mjs"
click node_helpers "https://github.com/artesgo/playwright-harness/blob/main/record.mjs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_server,node_shell,node_client,node_proxy,node_iframe,node_specapi,node_user toneBlue
class node_recording,node_selector,node_steps,node_replay,node_codegen,node_discovery,node_loading toneAmber
class node_parser,node_helpers toneMint
class node_app,node_specdir toneIndigo
```

## Components

### Harness runtime

- [HTTP server](https://github.com/artesgo/playwright-harness/blob/main/server.mjs): `server.mjs`
- [Harness page](https://github.com/artesgo/playwright-harness/blob/main/index.html): `index.html`
- [Harness UI](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`
- [App proxy](https://github.com/artesgo/playwright-harness/blob/main/server.mjs): `server.mjs`
- [App iframe](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`
- [Spec endpoint](https://github.com/artesgo/playwright-harness/blob/main/server.mjs): `server.mjs`

### Test authoring

- [Interaction recording](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`
- [Selector picking](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`
- [Step editing](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`
- [Step replay](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`
- [Test generation](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`
- [Spec discovery](https://github.com/artesgo/playwright-harness/blob/main/specs.mjs): `specs.mjs`
- [Spec loading](https://github.com/artesgo/playwright-harness/blob/main/harness.js): `harness.js`

### Step support

- [Step parser](https://github.com/artesgo/playwright-harness/blob/main/steps.mjs): `steps.mjs`
- [Recording helpers](https://github.com/artesgo/playwright-harness/blob/main/record.mjs): `record.mjs`

### Other components

- **Harness user**
- **Running app**
- **Test directory**

## Connections

- Harness user → Harness page: opens (evidence: `README.md`)
- HTTP server → Harness page: serves (evidence: `server.mjs`)
- HTTP server → App proxy: routes app requests (evidence: `server.mjs`)
- App proxy → Running app: forwards HTTP (evidence: `server.mjs`)
- Harness UI → App iframe: inspects (evidence: `README.md`)
- App iframe → App proxy: loads app through (evidence: `README.md`)
- Harness user → Interaction recording: records interactions (evidence: `README.md`)
- Interaction recording → Recording helpers: uses (evidence: `harness.js`)
- Interaction recording → Step editing: adds steps (evidence: `README.md`)
- Harness user → Selector picking: picks elements (evidence: `README.md`)
- Selector picking → Recording helpers: uses selector helpers (evidence: `harness.js`)
- Harness user → Step editing: edits steps (evidence: `README.md`)
- Harness user → Step replay: starts replay (evidence: `README.md`)
- Step replay → App iframe: runs actions in (evidence: `README.md`)
- Step editing → Recording helpers: groups waits (evidence: `harness.js`)
- Step editing → Test generation: generates test (evidence: `README.md`)
- Harness user → Test directory: configures (evidence: `README.md`)
- HTTP server → Spec endpoint: serves endpoint (evidence: `server.mjs`)
- Spec endpoint → Spec discovery: calls (evidence: `server.mjs`)
- Spec discovery → Test directory: reads specs
- Harness user → Spec loading: loads a test (evidence: `README.md`)
- Spec loading → Spec endpoint: fetches specs (evidence: `README.md`)
- Spec loading → Step parser: parses source (evidence: `harness.js`)
- Step parser → Step editing: returns steps (evidence: `harness.js`)
