A lean, opinionated Playwright + JavaScript (TDD) framework that stays clean, fast, and CI-ready.
It follows DRY / KISS / SOLID, uses simple ES6 Page Objects, and ships with truthful logs and reports.
- Engine: Playwright core (no external WebDriver)
- Build & Deps: npm +
package.json - Runner: Playwright Test (
test,test.beforeEach, projects/workers for parallel) - Style: TDD (you can layer BDD later)
- POM: ES6 classes in
src/pages/extendingBasePage - Reporting: Playwright HTML (local) + Allure (via Jenkins plugin / CLI)
- Logging:
log4js(+ optional Playwright listeners/custom reporter) - Test Data: Excel/JSON via
excelRead.js; specs consume via fixtures - Env config:
.env+config/config.jsonvia a ConfigManager
Patterns
- Singleton: Config, Logger
- Observer: listeners / custom reporter for events
- Factory: not needed β Playwright selects browser via CLI/projects
a) Build & Dependencies Β· b) Configuration Β· c) Core/Base Β· d) Tests & Page Objects Β· e) Utilities (fixtures, reporters, CI hooks)
Singleton (config/logging) Β· Observer (telemetry/reporting) Β· POM (stable, intentionβrevealing interactions)
Real-time log4js + artifacts (traces, screenshots, videos)
Excel/JSON β typed access in fixtures (no hard-coded data/secrets)
Projects/workers + stable sync (auto-waits, strict locators)
- β DRY, KISS, SOLID throughout
- β Reusable page objects & centralized configuration
- β Cross-browser / cross-platform ready
- β Parallel execution with stable synchronization
- β Version-control hygiene & CI/CD ready (Jenkins-friendly)
- Node.js β₯ 18 (LTS recommended)
- Git
git clone https://github.com/<you>/javaScript-playwrightNative-TAF.git
cd javaScript-playwrightNative-TAF
npm ci
npx playwright install --with-depsIf you plan to use environment flags like
ENV=QA, install cross-env:
npm i -D cross-env
# Headed mode (example using ENV)
npx cross-env ENV=QA playwright test --headed
# Filter by title or tag with grep
npx cross-env ENV=QA playwright test --grep "Home Page"
# Choose project and workers
npx cross-env ENV=QA playwright test --project=chromium --workers=2
# UI mode (interactive)
npx cross-env ENV=QA playwright test --ui
# Open Playwright HTML report after a run
npx playwright show-reportAuto-generated to playwright-report/. Open with:
npx playwright show-reportRaw data is produced by setting the reporter to include allure-playwright.
Example config snippet:
// playwright.config.js
reporter: [
['line'],
['html', { outputFolder: 'playwright-report', open: 'never' }],
['allure-playwright']
],
use: {
trace: 'retain-on-failure', screenshot: 'only-on-failure', video: 'retain-on-failure'
}Generate & open:
npx allure-commandline generate allure-results --clean -o allure-report
npx allure-commandline open allure-report- Install Allure Jenkins Plugin and Allure Commandline
- Pipeline snippet to publish:
allure includeProperties: false, jdk: '', results: [[path: 'allure-results']]Tip: Serve reports via CLI/CI rather than opening
index.htmlfrom disk to avoid browser CSP issues.
- Playwright Inspector
PWDEBUG=1 npx cross-env ENV=QA playwright test --project=chromium --headed- Traces, Screenshots, Videos
npx playwright show-trace test-results/**/trace.zip- Slow down actions
npx cross-env ENV=QA playwright test --headed --timeout=60000
# or configure slowMo in playwright.config.ts/js- Target a single spec or test
npx cross-env ENV=QA playwright test tests/specifications/homePage.spec.js
npx cross-env ENV=QA playwright test -g "Verify header"- Extra logging
Set log level in
log4js.json(e.g., DEBUG). - Network/console
page.on('console', msg => {/* ... */});
page.on('requestfailed', req => {/* ... */});{
"scripts": {
"test": "playwright test",
"test:QA": "cross-env ENV=QA playwright test",
"test:DEV": "cross-env ENV=DEV playwright test",
"report": "playwright show-report",
"allure:report": "allure-commandline generate allure-results --clean -o allure-report && allure-commandline open allure-report"
}
}Run with:
npm run test:QA
npm run report
npm run allure:reportAgent setup
npm ci
npx playwright install --with-depsRun tests
npx cross-env ENV=QA playwright test --reporter=line,html,allure-playwrightPublish
-
HTML Publisher
- Directory:
playwright-report - Index:
index.html
- Directory:
-
Allure Jenkins Plugin
- Results:
allure-results
- Results:
During early development, you can keep the job green and still see failures in reports by publishing reports from post steps. Avoid masking failures long term.
- Small, readable specs
- Page Objects hide selectors & flows
- One responsibility per module
- Keep fixtures dumb and fast
- Prefer getByRole/testId locators; avoid brittle CSS where possible
- Review logs & traces before changing waits
PLAYWRIGHTNATIVE/
ββ .vscode/
β ββ launch.json
ββ allure-results/
ββ config/
β ββ .env
β ββ config.json
ββ logs/
ββ node_modules/
ββ reports/
β ββ html-report/
β ββ index.html
ββ src/
β ββ core/
β β ββ base.page.js
β ββ pages/
β ββ utils/
β ββ configManager.js
β ββ excelRead.js
β ββ logger.js
β ββ testUtils.js
ββ test-results/
ββ testData/
β ββ testData.xlsx
ββ tests/
β ββ specifications/
β β ββ homePage.spec.js
β β ββ sanity.spec.js
β β ββ smoke.spec.js
β ββ fixtures.js
ββ .gitignore
ββ Jenkinsfile
ββ package-lock.json
ββ package.json
ββ playwright.config.js