Skip to content

jay-yeluru/playwright-demo-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

47 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 Playwright Demo JS

A production-grade end-to-end test automation framework built with Playwright and JavaScript, featuring a fully automated CI/CD pipeline with a live test dashboard hosted on GitHub Pages.

πŸ”— Live Dashboard


πŸ“‹ Table of Contents


✨ Features

  • Cross-browser testing across Chrome, Firefox, Safari and Edge
  • Automated HTML and JSON report generation on every run
  • Live test dashboard with run history, pass rates and trend charts hosted on GitHub Pages
  • Auto-cleanup of old reports to keep the repository lean
  • Fully automated CI/CD via GitHub Actions β€” no external tools or paid services required

πŸ›  Tech Stack

Tool Purpose
Playwright Test framework
GitHub Actions CI/CD pipeline
GitHub Pages Dashboard hosting
Node.js 22 Runtime

πŸ“ Project Structure

playwright-demo-js/
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   β”œβ”€β”€ generate-dashboard.js         # Builds the live HTML dashboard
β”‚   β”‚   └── generate-dashboard-local.js   # Run dashboard locally with mock data
β”‚   └── workflows/
β”‚       β”œβ”€β”€ run-tests.yml                 # Runs Playwright tests on demand
β”‚       └── publish-report.yml            # Publishes report to GitHub Pages
β”œβ”€β”€ e2e/
β”‚   └── example.spec.js                   # Test specs
β”œβ”€β”€ playwright.config.js                  # Playwright configuration
β”œβ”€β”€ package.json
└── README.md

πŸš€ Getting Started

Prerequisites

  • Node.js >= 22
  • npm

Installation

# Clone the repository
git clone https://github.com/jay-yeluru/playwright-demo-js.git
cd playwright-demo-js

# Install dependencies
npm install

# Install Playwright browsers
npx playwright install

πŸ§ͺ Running Tests

Run all tests

npm test

Run by browser

npm run test:chrome
npm run test:firefox
npm run test:safari
npm run test:edge

Run smoke tests only

npm run test:smoke

View the HTML report

npm run show-report

Generate dashboard locally

npm run dashboard:local

βš™οΈ CI/CD Pipeline

The pipeline is split into two workflows:

run-tests.yml

Triggered manually via workflow_dispatch. Allows selecting the browser to run tests on.

Inputs:
  browser: chrome | firefox | safari | edge (default: chrome)

Steps:

  1. Checkout repository
  2. Setup Node.js 22
  3. Install dependencies via npm ci
  4. Install Playwright browsers
  5. Run tests
  6. Upload reports as artifacts

publish-report.yml

Triggered automatically after run-tests.yml completes (pass or fail).

Steps:

  1. Checkout gh-pages branch
  2. Fetch the dashboard generator script
  3. Download reports artifact
  4. Regenerate dashboard with updated history
  5. Commit and push to gh-pages

πŸ“Š Test Dashboard

The live dashboard is hosted at https://jay-yeluru.github.io/playwright-demo-js/ and updates automatically after every CI run.

Dashboard features

  • Stats cards β€” Total runs, passed runs, failed runs and overall pass rate
  • Sparkline chart β€” Pass rate trend across the last 20 runs
  • Latest run banner β€” Quick summary of the most recent run with a direct report link
  • Run history table β€” Full history with status, branch, browser, pass/fail counts, pass rate bar and link to the full Playwright HTML report
  • Auto-cleanup β€” Keeps the latest 10 runs per branch (configurable via KEEP_RUNS)

GitHub Pages setup

  1. Create an orphan gh-pages branch:
git switch --orphan gh-pages
git commit --allow-empty -m "init: gh-pages"
git push origin gh-pages
git checkout develop
  1. Go to Settings β†’ Pages β†’ Source, select gh-pages branch and / (root)

  2. Go to Settings β†’ Actions β†’ General β†’ Workflow permissions and enable Read and write permissions


πŸ”§ Configuration

playwright.config.js

Option Value Description
testDir ./e2e Test files location
outputDir test-artifacts Screenshots, traces, videos
timeout 30000ms Per-test timeout
retries 2 (CI) / 0 (local) Retry on failure
workers 1 (CI) / auto (local) Parallel workers
reporter (CI) html, json, github CI reporters
reporter (local) html, json, list Local reporters

Reports output

reports/
  index.html          ← Playwright HTML report
  test-results.json   ← JSON report (used by dashboard generator)
test-artifacts/       ← Screenshots, videos, traces

Environment variables (dashboard script)

Variable Description Default
BRANCH Git branch name required
RUN_ID GitHub Actions run ID required
BROWSER Browser used for the run required
REPORT_PATH Path to the downloaded reports required
KEEP_RUNS Number of runs to keep per branch 10

πŸ“„ License

ISC Β© Jay Yeluru

Contributors