npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

harwise

v0.2.3

Published

CLI tool for processing HAR files to generate Insomnia collections, functional tests, HTML reports, and more

Downloads

27

Readme

harwise

A CLI tool for processing HAR (HTTP Archive) files to generate functional tests, HTML reports, Insomnia collections, curl suites, and perform regression analysis.

npm version CI Node.js Version License: MIT GitHub last commit GitHub issues GitHub stars

✨ Features

  • Functional Test Generation - Generate Node.js/TypeScript tests with assertions, timing validation, and variable extraction
  • HTML Reports - Self-contained reports with performance metrics and comparison views
  • HAR Comparison - Detect performance regressions with configurable thresholds
  • Insomnia Collections - Export API requests to Insomnia v4 format with environment variables
  • Curl Suites - Generate shell scripts for manual testing with masked headers
  • CI/CD Ready - Static outputs, no external dependencies, perfect for automated workflows

🚀 Quick Start

Installation

npm install -g harwise
# or
npx harwise --help

Basic Usage

# Generate functional tests from HAR file
harwise gen tests my-api.har --out tests/

# Run tests with HTML report
harwise test --report report.html

# Compare HAR files for regressions
harwise compare baseline.har new.har

# Generate Insomnia collection
harwise gen insomnia my-api.har --out collection.json

# Create curl suite
harwise gen curl my-api.har --out suite.sh --strict

# Compare with templated paths (default)
harwise compare old.har new.har

# Disable templating if you want full URLs
harwise compare old.har new.har --no-template

📖 Commands

harwise stats <harFile>

Get a quick summary of HAR file contents.

harwise stats my-api.har

Output:

HAR Stats: my-api.har
Total API requests: 24
Average time: 145.67ms
Average size: 2.3 KB
Status codes: { '200': 22, '201': 2 }

harwise gen tests <harFile>

Generate functional tests from HAR file.

harwise gen tests my-api.har --out tests/ --config hw.config.json

Options:

  • --out <dir> - Output directory (default: tests/)
  • --config <file> - Configuration file path

Generated Files:

  • tests/test_0.spec.js, tests/test_1.spec.js, ... - Individual test files
  • tests/.harwise.manifest.json - Test execution manifest
  • tests/.harwise.env.json - Extracted variables (after running tests)

harwise test

Run generated functional tests.

harwise test --env .env --report report.html --tag "build-123"

Options:

  • --env <file> - Environment variables file
  • --report <file> - Generate HTML report
  • --tag <label> - Tag for report labeling

Features:

  • ✅ Status code validation
  • ✅ Content-type assertions
  • ✅ Timing performance assertions
  • ✅ JSON schema validation
  • ✅ Variable extraction and chaining
  • ✅ Environment variable support
  • ✅ HTML reports generated even when tests fail

harwise compare <baselineHar> <newHar>

Compare two HAR files for performance regressions.

harwise compare baseline.har new.har --time-regress 10 --size-regress 15 --out comparison.md

Options:

  • --time-regress <pct> - Time regression threshold (default: 10%)
  • --size-regress <pct> - Size regression threshold (default: 15%)
  • --out <file> - Output file for Markdown report
  • --report <file> - Generate HTML comparison report

Exit Codes:

  • 0 - No regressions
  • 2 - Regressions detected

harwise gen insomnia <harFile>

Generate Insomnia v4 collection.

harwise gen insomnia my-api.har --out collection.json --env staging.env.json

Options:

  • --out <file> - Output file
  • --env <file> - Environment file for additional variables

Features:

  • Auto-extracts Bearer tokens into {{ auth_token }}
  • Normalizes URLs with {{ base_url }}
  • Masks sensitive headers
  • Handles JSON and form-encoded bodies

harwise gen curl <harFile>

Generate curl suite for manual testing.

harwise gen curl my-api.har --out suite.sh --strict

Options:

  • --out <file> - Output file (default: suite.sh)
  • --strict - Add set -euo pipefail for strict error handling

Features:

  • Masks authorization and cookie headers
  • Includes original timing/size as comments
  • Supports all HTTP methods and body types

⚙️ Configuration

Create a hw.config.json file for advanced configuration:

{
  "baseUrl": "https://api.example.com",
  "maskHeaders": ["authorization", "cookie", "x-api-key"],
  "assertions": {
    "global": {
      "statusRange": [200, 399],
      "maxTimePctOverSample": 25
    },
    "byUrl": [
      {
        "match": "/v1/users$",
        "jsonpath": [
          { "path": "$.data[*].id", "exists": true },
          { "path": "$.data", "minLength": 1 }
        ]
      }
    ]
  },
  "extract": [
    { "match": "/login$", "from": "$.access_token", "to": "auth_token" },
    { "match": "/v1/users/(\\d+)", "from": "$.id", "to": "last_user_id" }
  ],
  "substitute": [
    { "match": "/v1/users/\\d+", "pattern": "(\\d+)", "var": "last_user_id" }
  ]
}

🌍 Global Options

All commands support these global options:

  • --include <regex> - Include only URLs matching regex
  • --exclude <regex> - Exclude URLs matching regex
  • --mask-headers <list> - Comma-separated list of headers to mask
  • --base-url <url> - Base URL for origin normalization
  • --no-template - Disable path templating of dynamic IDs/UUIDs
  • --tag <label> - Tag for report labeling

📊 HTML Reports

Generated reports include:

  • Summary Tiles - Total/passed/failed tests, P50/P95 latency
  • Test Results Table - Sortable by name, status, time, assertions
  • Performance Comparison - When comparing HARs, shows regressions
  • Embedded Assets - No external dependencies, CI/CD safe

🔧 Development

Prerequisites

  • Node.js >= 20.0.0
  • npm or yarn

Setup

git clone https://github.com/jcopperman/harwise.git
cd harwise
npm install
npm run build

Testing

npm test

Building

npm run build

📋 CI/CD Integration

GitHub Actions Example

See the complete workflow file: .github/workflows/ci.yml

The workflow includes:

  • Multi-Node testing (Node 20.x and 22.x)
  • CLI command testing with fixture files
  • Artifact uploads for reports and generated files
  • Release automation for the main branch

Basic CI/CD Setup

name: API Testing
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: 20 }

      - name: Install harwise
        run: npm install -g harwise

      - name: Generate Tests
        run: harwise gen tests ./artifacts/api.har --out tests/ --config hw.config.json

      - name: Run Tests
        run: harwise test --env .env --report test-report.html

      - name: Compare Performance
        run: harwise compare ./artifacts/baseline.har ./artifacts/api.har --time-regress 10

      - name: Upload Report
        uses: actions/upload-artifact@v4
        with:
          name: test-report
          path: test-report.html

🔒 Security & Privacy

  • Header Masking - Automatically masks authorization, cookie, set-cookie headers
  • Body Size Limits - Respects --keep-bodies flag (default: omit bodies >1MB)
  • No External Calls - Pure static analysis, no network requests during generation
  • CI/CD Safe - All outputs are static files with no external dependencies

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes and add tests
  4. Run tests: npm test
  5. Commit your changes: git commit -am 'Add my feature'
  6. Push to the branch: git push origin feature/my-feature
  7. Submit a pull request

📝 License

MIT License - see LICENSE file for details.

🙏 Acknowledgments


harwise - Making API testing from HAR files simple and powerful.