How openqa-labs/openqa works
1. What this repository is
OpenQA is a Node.js package that combines three things in one repo: an agent runtime for browser testing, a CLI that scaffolds test harnesses, and generators/templates for multiple test styles. The core value proposition is that tests are written in natural language while Playwright still executes the browser actions.
2. Primary runtime boundary
The main execution boundary is between the test process and the agent process. User-authored BDD/YAML test code calls into openqa, and OpenQA spins up an in-process Playwright MCP server exposed over localhost HTTP/SSE. The AI provider SDK then connects to that MCP endpoint and drives the browser through MCP tools.
3. Core library entry point
src/index.js is the package surface area. It likely re-exports the agent runtime, provider factories, and YAML utilities so consumers can use OpenQA from step definitions or generated tests without reaching into internal files.
4. Agent subsystem
src/agent/ contains the orchestration layer:
- Orchestrator.js coordinates the overall agent run.
- SessionManager.js preserves conversation state per browser context so a scenario can continue across multiple steps.
- Logger.js handles verbose step-by-step output and secret redaction.
- createMcpServer.js creates the Playwright MCP server that the AI client talks to.
- systemPrompt.js defines the instruction set given to the model.
This is the heart of the “natural language to browser actions” flow.
5. Provider adapters
src/agent/providers/claudeCode.js and src/agent/providers/openCode.js are the integration boundary to external AI tooling. They wrap two different provider ecosystems:
- Claude Code SDK
- OpenCode SDK
The repo treats model/provider choice as a thin adapter layer, while the rest of OpenQA stays provider-agnostic.
6. Browser execution model
The agent does not talk to a fake browser API; it drives the real Playwright page or browser context that the test already owns. The README’s flow shows the step definition passing page or context into runAgent(...), which then routes browser actions through MCP tools like navigation and clicking. This shared-browser design is central to the architecture.
7. CLI and scaffolding subsystem
src/cli/ is responsible for project setup:
- bin.js is the command-line entry.
- init.js creates a new .openqa/ harness in a target project.
- generate.js supports generation tasks.
The CLI is not the test runner itself; it prepares a runnable harness that sits alongside the user’s project.
8. Template-driven project layout
src/cli/templates/ contains complete starter harnesses for three execution styles:
- playwright-bdd
- cucumber
- playwright-yaml
These templates include feature files, step definitions, Playwright config, package manifests, and env schema files. openqa init copies one of these templates into the user project, making the generated .openqa/ folder the user-editable boundary.
9. YAML test pipeline
src/yaml/ is the alternate test authoring path. schema.js defines the structure of the YAML test format, and generator.js turns YAML specs into executable test artifacts. This subsystem exists alongside BDD support and is exposed via the YAML template and example project.
10. Examples as integration references
examples/ demonstrates the three supported styles end-to-end:
- examples/playwright-bdd
- examples/cucumberjs
- examples/playwright-yaml
These are not just demos; they show the intended dependency graph between generated harness, Playwright config, feature/spec files, and the OpenQA runtime.
11. Docs and release tooling
docs/ is the product documentation site, while .github/workflows/release.yml handles publishing automation. These do not affect runtime architecture, but they define how the package is documented and shipped.
12. Overall data flow
The dominant flow is: user-authored feature/YAML step → OpenQA agent API → MCP server creation → provider SDK connection → Playwright browser actions → test assertion/result. The scaffolding flow is separate: CLI init → template copy → user edits generated harness → test runner executes against the core agent runtime.
Main entry points: Orchestrator.js Orchestrator · index.js Package API · examples Examples · templates Templates
Components 22
Agent runtime
Natural-language browser execution over Playwright and MCP
- Package API · Main export surface for consumers
src/index.js - Agent API · Agent subsystem exports
src/agent/index.js - Orchestrator · Coordinates a full agent run
src/agent/Orchestrator.js - Session state · Maintains per-browser-context continuity
src/agent/SessionManager.js - Logger · Verbose output and secret redaction
src/agent/Logger.js - MCP server · Creates the Playwright MCP endpoint
src/agent/createMcpServer.js - System prompt · Instruction set for the AI provider
src/agent/systemPrompt.js - Provider adapters · Thin wrappers for external model toolchains
src/agent/providers - Claude Code · Claude Code SDK integration
src/agent/providers/claudeCode.js - OpenCode · OpenCode SDK integration
src/agent/providers/openCode.js
CLI scaffolding
Project initialization and template generation
- CLI entry · Package executable entry point
src/cli/bin.js - Init command · Creates a new OpenQA harness in a target project
src/cli/init.js - Generate command · Runs generation tasks
src/cli/generate.js - Templates · Starter harnesses copied into user projects
src/cli/templates - BDD template · Playwright BDD harness layout
src/cli/templates/playwright-bdd - Cucumber template · Cucumber harness layout
src/cli/templates/cucumber - YAML template · Playwright YAML harness layout
src/cli/templates/playwright-yaml
YAML pipeline
Schema and generator for YAML-authored tests
- YAML schema · Structure of YAML test files
src/yaml/schema.js - YAML generator · Turns YAML specs into executable tests
src/yaml/generator.js
Docs & release
Documentation and publishing automation
- Docs site · Product documentation and quickstart guides
docs - Release workflow · GitHub Actions release pipeline
.github/workflows/release.yml
Other components
- Examples · End-to-end usage samples for all supported styles
examples
Connections 27
- Package API → Agent API: re-exports · Package surface exposes agent runtime APIs
- Package API → CLI entry: exposes · Package also ships the CLI entry
- Agent API → Orchestrator: uses · Agent API centers on orchestration
- Orchestrator → Session state: tracks · Keeps scenario state across steps
- Orchestrator → Logger: logs · Emits step-by-step trace output
- Orchestrator → MCP server: spins up · Creates the browser MCP bridge
- Orchestrator → System prompt: instructs · Feeds the model its operating instructions
- Orchestrator → Provider adapters: delegates to · Uses provider-specific AI client adapters
- Provider adapters → Claude Code: includes · Claude Code integration
- Provider adapters → OpenCode: includes · OpenCode integration
- Claude Code → MCP server: connects · Provider client talks to the MCP endpoint
- OpenCode → MCP server: connects · Provider client talks to the MCP endpoint
- CLI entry → Init command: dispatches · CLI entry routes to init
- CLI entry → Generate command: dispatches · CLI entry routes to generate
- Init command → Templates: copies · Initializes a project from a template
- Templates → BDD template: contains · BDD starter layout
- Templates → Cucumber template: contains · Cucumber starter layout
- Templates → YAML template: contains · YAML starter layout
- YAML template → YAML schema: aligns with · Template matches YAML test structure
- YAML template → YAML generator: uses · Generated harness executes YAML tests
- YAML generator → YAML schema: validates against · Generator consumes the YAML spec shape
- Examples → Package API: exercise · Examples demonstrate the core runtime
- Examples → BDD template: mirror · Example projects reflect generated harnesses
- Examples → Cucumber template: mirror · Example projects reflect generated harnesses
- Examples → YAML template: mirror · Example projects reflect generated harnesses
- Docs site → Package API: documents · Docs explain the main package flow
- Release workflow → Package API: publishes · Workflow packages and releases the library