How mnashed13/playwright-testing-framework works
Purpose and Entry Points
This is a Node.js TypeScript automated-testing framework combining Cucumber BDD scenarios with Playwright. It has separate UI/browser and API test suites. Main execution is through npm scripts in package.json, with Cucumber profiles/configuration in cucumber.cjs and browser settings in playwright.config.ts.
UI BDD Test Pipeline
UI scenarios begin as Gherkin features, are bound to Cucumber step definitions, then drive browser interactions through page objects:
• src/features/login.feature
• src/steps/login.steps.ts
• src/pages/login.page.ts
The UI suite is invoked by npm test; Cucumber is the scenario orchestrator and Playwright supplies browser automation and assertions.
UI Runtime Lifecycle and State Boundary
A custom Cucumber World holds per-scenario Playwright state, while hooks establish and dispose browser/page resources around scenarios. Environment handling is isolated from feature and page code:
• src/support/world.ts
• src/support/hooks.ts
• src/support/env.ts
This separates declarative scenarios and step logic from browser lifecycle, credentials, runtime browser selection, and environment-dependent values.
Page-Object Automation Layer
Page objects encapsulate navigation, locators, and UI operations; steps should express business actions rather than selectors. BasePage provides shared browser-page behavior, and LoginPage specializes login interactions:
• src/pages/base.page.ts
• src/pages/login.page.ts
• src/test-data/test-data.ts
Test data is kept outside scenario and page control flow, reducing direct dependence on credentials or fixed UI inputs.
API BDD Test Pipeline
API tests are a parallel Cucumber suite with no browser-page dependency. Features select endpoint behaviors, step definitions issue requests via a shared client, and the API World retains scenario request/response context:
• api-tests/features/echo-api.feature
• api-tests/steps/echo-api.steps.ts
• api-tests/support/api-client.ts
The user endpoint coverage follows the same pattern in api-tests/features/user-api.feature and api-tests/steps/users-api.steps.ts. API execution is exposed through npm run test:api, smoke filtering, and Echo-specific scripts.
API Diagnostics and Reporting
The API client boundary centralizes external HTTP communication. Supporting code formats reproducible curl representations and generates test reports:
• api-tests/support/world.ts
• api-tests/support/curl-formatter.ts
• api-tests/support/report-generator.ts
Generated artifacts include Cucumber HTML/JSON under reports/ and API report generation entry code in api-tests/generate-report.ts. Browser-oriented output is published under playwright-report/.
Build, CI, and Release Boundaries
Source TypeScript is compiled into committed/generated JavaScript under dist/, which mirrors the UI suite structure:
• tsconfig.json
• dist/steps/login.steps.js
• dist/support/world.js
CI is represented across GitHub Actions, Buildkite, and Azure pipeline definitions. GitHub Actions runs API tests and semantic-release; release flow treats passing tests and report artifacts as a release gate:
• .github/workflows/api-tests.yml
• .github/workflows/semantic-release.yml
• .buildkite/pipeline.yml
External dependencies/material runtimes are Node.js, Cucumber.js, Playwright, target web applications for UI testing, and target HTTP services for API testing.
Main entry points: login.steps.ts Login steps · login.page.ts LoginPage · echo-api.steps.ts API step definitions · api-client.ts API client
Components 22
UI BDD Suite
- Cucumber UI runner
cucumber.cjs - Login feature
src/features/login.feature - Login steps
src/steps/login.steps.ts - UI World · Holds per-scenario Playwright state.
src/support/world.ts - UI hooks · Creates and disposes browser resources per scenario.
src/support/hooks.ts - Environment settings
src/support/env.ts - BasePage
src/pages/base.page.ts - LoginPage · Encapsulates login navigation and locators.
src/pages/login.page.ts - Test data
src/test-data/test-data.ts - Playwright · Drives browser interactions and assertions.
playwright.config.ts - Target web app
API BDD Suite
- API features · Covers echo and user endpoint behavior.
api-tests/features/echo-api.feature - API step definitions · Echo and user scenarios bind endpoint actions.
api-tests/steps/echo-api.steps.ts - API World · Retains request and response state.
api-tests/support/world.ts - API client · Centralizes external HTTP requests.
api-tests/support/api-client.ts - Target HTTP services
- curl formatter · Formats reproducible request commands.
api-tests/support/curl-formatter.ts - API report generator · Generates Cucumber HTML and JSON artifacts.
api-tests/support/report-generator.ts
Runtime & Delivery
- npm scripts · Runs UI and API test commands.
package.json - TypeScript build · Compiles suite source into dist/.
tsconfig.json - Compiled UI suite
dist/steps/login.steps.js - CI and release · Runs API tests and semantic release after test gates.
.github/workflows/api-tests.yml
Connections 22
- npm scripts → Cucumber UI runner: npm test
- npm scripts → API features: test:api
- Cucumber UI runner → Login feature: executes
- Login feature → Login steps: binds steps
- Login steps → LoginPage: uses
- Login steps → UI World: reads state
- UI hooks → UI World: initializes
- UI hooks → Playwright: manages
- Environment settings → UI hooks: configures
- BasePage → LoginPage: shared behavior
- LoginPage → Playwright: automates through
- LoginPage → Target web app: interacts with
- Test data → Login steps: supplies inputs
- API features → API step definitions: binds steps
- API step definitions → API World: stores context
- API step definitions → API client: issues requests
- API client → Target HTTP services: HTTP calls
- API client → curl formatter: diagnostics
- API World → API report generator: report data
- TypeScript build → Compiled UI suite: emits
- CI and release → npm scripts: runs test gates
- CI and release → API report generator: publishes artifacts