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

@hegeldev/hegel

v0.2.2

Published

Property-based testing for TypeScript

Downloads

5,086

Readme

[!IMPORTANT] We're excited you're checking out Hegel! Hegel is in beta, and we'd love for you to try it and report any feedback.

As part of our beta, we may make breaking changes if it makes Hegel a better property-based testing library. If that instability bothers you, please check back in a few months for a stable release!

See https://hegel.dev/compatibility for more details.

Hegel for TypeScript

Hegel is a property-based testing library for TypeScript. Hegel is based on Hypothesis, using the Hegel protocol.

Installation

To install: npm install --save-dev @hegeldev/hegel.

Hegel requires Node 16+. Bun and Deno are not currently supported.

Hegel will use uv to install the required hegel-core server component. If uv is already on your path, it will use that, otherwise it will download a private copy of it to ~/.cache/hegel and not put it on your path. See https://hegel.dev/reference/installation for details.

Quickstart

Here's a quick example of how to write a Hegel test:

import { test } from "vitest";
import * as hegel from "@hegeldev/hegel";
import * as gs from "@hegeldev/hegel/generators";

function mySort(ls: number[]): number[] {
  const result = [...ls].sort((a, b) => a - b);
  return [...new Set(result)];
}

test("my_sort matches builtin", () =>
  hegel.test((tc) => {
    const vec1 = tc.draw(gs.arrays(gs.integers()));
    const vec2 = mySort(vec1);
    const sorted = [...vec1].sort((a, b) => a - b);
    if (JSON.stringify(sorted) !== JSON.stringify(vec2)) {
      throw new Error(`sort mismatch: ${JSON.stringify(sorted)} != ${JSON.stringify(vec2)}`);
    }
  }));

This test will fail when run with vitest! Hegel will produce a minimal failing test case for us:

Draw 1: [0, 0]
Error: sort mismatch: [0,0] != [0]

Hegel reports the minimal example showing that our sort is incorrectly dropping duplicates. If we remove the new Set(...) deduplication from mySort(), this test will then pass (because it's just comparing the standard sort against itself).

Async tests

For async tests, use hegel.testAsync:

import { test } from "vitest";
import * as hegel from "@hegeldev/hegel";
import * as gs from "@hegeldev/hegel/generators";

test("fetch returns a value matching its input", () =>
  hegel.testAsync(async (tc) => {
    const id = tc.draw(gs.integers({ minValue: 1, maxValue: 1000 }));
    const result = await fetchUser(id);
    if (result.id !== id) {
      throw new Error(`Expected id=${id}, got ${result.id}`);
    }
  }));