Files
Charon/.github/skills/test-e2e-playwright-coverage.SKILL.md
akanealw eec8c28fb3
Some checks are pending
Go Benchmark / Performance Regression Check (push) Waiting to run
Cerberus Integration / Cerberus Security Stack Integration (push) Waiting to run
Upload Coverage to Codecov / Backend Codecov Upload (push) Waiting to run
Upload Coverage to Codecov / Frontend Codecov Upload (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (go) (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (javascript-typescript) (push) Waiting to run
CrowdSec Integration / CrowdSec Bouncer Integration (push) Waiting to run
Docker Build, Publish & Test / build-and-push (push) Waiting to run
Docker Build, Publish & Test / Security Scan PR Image (push) Blocked by required conditions
Quality Checks / Auth Route Protection Contract (push) Waiting to run
Quality Checks / Codecov Trigger/Comment Parity Guard (push) Waiting to run
Quality Checks / Backend (Go) (push) Waiting to run
Quality Checks / Frontend (React) (push) Waiting to run
Rate Limit integration / Rate Limiting Integration (push) Waiting to run
Security Scan (PR) / Trivy Binary Scan (push) Waiting to run
Supply Chain Verification (PR) / Verify Supply Chain (push) Waiting to run
WAF integration / Coraza WAF Integration (push) Waiting to run
changed perms
2026-04-22 18:19:14 +00:00

5.7 KiB
Executable File

name, version, description, author, license, tags, compatibility, requirements, environment_variables, parameters, outputs, metadata
name version description author license tags compatibility requirements environment_variables parameters outputs metadata
test-e2e-playwright-coverage 1.0.0 Run Playwright E2E tests with code coverage collection using @bgotink/playwright-coverage Charon Project MIT
testing
e2e
playwright
coverage
integration
os shells
linux
darwin
bash
name version optional
node >=18.0 false
name version optional
npx >=1.0 false
name description default required
PLAYWRIGHT_BASE_URL Base URL of the Charon application under test http://localhost:8080 false
name description default required
PLAYWRIGHT_HTML_OPEN Controls HTML report auto-open behavior (set to 'never' for CI/non-interactive) never false
name description default required
CI Set to 'true' when running in CI environment false
name type description default required
project string Browser project to run (chromium, firefox, webkit) chromium false
name type description path
coverage-e2e directory E2E coverage output directory with LCOV and HTML reports coverage/e2e/
name type description path
playwright-report directory HTML test report directory playwright-report/
name type description path
test-results directory Test artifacts and traces test-results/
category subcategory execution_time risk_level ci_cd_safe requires_network idempotent
test e2e-coverage medium low true true true

Test E2E Playwright Coverage

Overview

Runs Playwright end-to-end tests with code coverage collection using @bgotink/playwright-coverage. This skill collects V8 coverage data during test execution and generates reports in LCOV, HTML, and JSON formats suitable for upload to Codecov.

IMPORTANT: This skill starts the Vite dev server (not Docker) because V8 coverage requires access to source files. Running coverage against the Docker container will result in 0% coverage.

Mode Base URL Coverage Support
Docker (localhost:8080) No - Shows "Unknown% (0/0)"
Vite Dev (localhost:5173) Yes - Real coverage data

Prerequisites

  • Node.js 18.0 or higher installed and in PATH
  • Playwright browsers installed (npx playwright install)
  • @bgotink/playwright-coverage package installed
  • Charon application running (default: http://localhost:8080, use docker-rebuild-e2e when app/runtime inputs change or the container is not running)
  • Test files in tests/ directory using coverage-enabled imports

Usage

Basic Usage

Run E2E tests with coverage collection:

.github/skills/scripts/skill-runner.sh test-e2e-playwright-coverage

Browser Selection

Run tests in a specific browser:

# Firefox (default)
.github/skills/scripts/skill-runner.sh test-e2e-playwright-coverage --project=firefox

# Firefox
.github/skills/scripts/skill-runner.sh test-e2e-playwright-coverage --project=firefox

CI/CD Integration

For use in GitHub Actions or other CI/CD pipelines:

- name: Run E2E Tests with Coverage
  run: .github/skills/scripts/skill-runner.sh test-e2e-playwright-coverage
  env:
    PLAYWRIGHT_BASE_URL: http://localhost:8080
    CI: true

- name: Upload E2E Coverage to Codecov
  uses: codecov/codecov-action@v5
  with:
    files: ./coverage/e2e/lcov.info
    flags: e2e

Parameters

Parameter Type Required Default Description
project string No firefox Browser project: chromium, firefox, webkit

Environment Variables

Variable Required Default Description
PLAYWRIGHT_BASE_URL No http://localhost:8080 Application URL to test against
PLAYWRIGHT_HTML_OPEN No never HTML report auto-open behavior
CI No "" Set to "true" for CI environment behavior

Outputs

Success Exit Code

  • 0: All tests passed and coverage generated

Error Exit Codes

  • 1: One or more tests failed
  • Non-zero: Configuration or execution error

Output Directories

  • coverage/e2e/: Coverage reports (LCOV, HTML, JSON)
    • lcov.info - LCOV format for Codecov upload
    • coverage.json - JSON format for programmatic access
    • index.html - HTML report for visual inspection
  • playwright-report/: HTML test report with results and traces
  • test-results/: Test artifacts, screenshots, and trace files

Viewing Coverage Reports

Coverage HTML Report

# Open coverage HTML report
open coverage/e2e/index.html

Playwright Test Report

npx playwright show-report --port 9323

Coverage Data Format

The skill generates coverage in multiple formats:

Format File Purpose
LCOV coverage/e2e/lcov.info Codecov upload
HTML coverage/e2e/index.html Visual inspection
JSON coverage/e2e/coverage.json Programmatic access
  • test-e2e-playwright - E2E tests without coverage
  • test-frontend-coverage - Frontend unit test coverage with Vitest
  • test-backend-coverage - Backend unit test coverage with Go

Notes

  • Coverage Source: Uses V8 coverage (native, no instrumentation needed)
  • Performance: ~5-10% overhead compared to tests without coverage
  • Sharding: When running sharded tests in CI, coverage files must be merged
  • LCOV Merge: Use lcov -a file1.info -a file2.info -o merged.info to merge

Last Updated: 2026-01-18 Maintained by: Charon Project Team