Automate HAR comparisons in your CI pipeline
⚡ HAR Guard CI — capture and compare HAR files to detect performance regressions in your web app, right from your CI pipeline. Keep every deployment honest with reproducible, data-driven checks.
npm install --save-dev har-guard-ci
- Deterministic performance gates for every branch.
- Markdown or JSON reports ready for CI logs and PR comments.
- Drop-in npm scripts that play nicely with existing E2E suites.
CI-native performance guardrails
Plug HAR Guard directly into your pipeline to flag regressions before they reach production.
Fast feedback for every deploy
Capture fresh HARs on demand and compare them against a known-good baseline within minutes.
Works with your existing tooling
Use Playwright to record traffic, run comparisons in Node, and post rich Markdown reports to your PRs.
Essential commands
capture
Records a HAR for any public or authenticated URL using Playwright and writes the archive to disk.
npx har-guard capture https://example.com artifacts/example.harcompare
Inspects two HAR files and fails when timing or payload thresholds are exceeded.
npx har-guard compare har/baseline.har har/candidate.har --reporter markdownInstallation
Install the package alongside your end-to-end tooling. Playwright is only necessary when you want to capture new HAR files.
npm install --save-dev har-guard-cinpm install --save-dev playwrightPlaywright is required only when using the capture command.
Capturing a HAR
Install Playwright and run the capture command with the URL you want to measure and the output .har file path. The command launches Chromium, waits for the page to finish loading, and writes the HAR file to the given path.
npx har-guard capture https://example.com artifacts/example.harCommit the resulting HAR file to your repository so future changes can be compared against it.
Comparing HAR files
Use the compare command to detect regressions between a baseline and a candidate HAR. If thresholds are exceeded or new requests appear, the command exits with a non-zero status code so your CI job fails.
npx har-guard compare har/baseline.har har/candidate.har --reporter markdownRunning in CI
Wire HAR Guard into your GitHub Actions workflow (or any CI that can run Node) so every pull request is validated before merging.
name: HAR Guard
on:
pull_request:
jobs:
compare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- name: Compare HAR files
run: npx har-guard compare har/baseline.har har/candidate.har --reporter markdownIf regressions are found, the step exits with status code 1 and the workflow fails, keeping performance budgets intact.
Explore the demo repository
A complete example repository—including baseline and candidate HAR files, npm scripts, and a reusable GitHub Actions workflow—is available under examples/demo-repo. Use it as a reference for wiring HAR Guard into your own project.