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

@averri/testgen

v0.1.0-alpha.0

Published

Averri test generator: derives tests/averri/*.gen.test.ts (auth matrix, precondition, postcondition, event, consumer, invariant, pitfall suites) from the Semantic IR

Readme

@averri/testgen

Generates tests/averri/<owner>.gen.test.ts from the Semantic IR (SPEC-CONTRACTS §9). Pure: a function of (graph, options) with no IO and no randomness, so the compiler owns writing, staleness (A6001) and deletion of generated files. Depends on @averri/ir only; the emitted files import vitest, fast-check and the test-harness surface of @averri/contracts.

API

import { generateTests, planTests, deriveTestNodes, sourceHashOf, parseGeneratedHeader, isGeneratedTestStale } from "@averri/testgen";

generateTests(graph, { actors: ["anonymous", "member", "admin"], generatedDir: "tests/averri" });
// -> [{ path: "tests/averri/Team.inviteMember.gen.test.ts", content, hash, owner: "Action:Team.inviteMember", tests: ["Test:gen/Team.inviteMember.auth-matrix", ...] }, ...]

planTests(graph, options);        // the suites (future Test nodes) with covers, sourceHash and it.todo reasons
deriveTestNodes(graph, options);  // { nodes: TestNode[], edges: verifiedBy Edge[] } for the compiler to add to the graph
sourceHashOf(graph, ownerId);     // the `hash:` of the owner's file, computed from the graph alone
isGeneratedTestStale(testNode, fileContentOrNull); // A6001

Options (GenerateOptions): generatedDir (config.test.generatedDir, default tests/averri), configFile (averri.config.ts), entryPoint (default meta.stack.entryPoints[0]), actors (fixture names from config.actors; anonymous is always first), numRuns (10), averriVersion, only (Test or owner ids).

What is generated

| Owner | Suites | |---|---| | Action / Query with policy | auth-matrix: one request per fixture; expected decision computed at test time by h.policyDecision; predicate policies get a second row per fixture with the predicate falsified | | Action | precondition (a violating input per tier-1 clause, a falsifying fixture per tier-2 clause, one all-satisfied call), postcondition (fc.asyncProperty over the valid input), event (exactly-N / min / max), pitfall.idempotency | | Entity with invariant | invariant: current rows + "1–5 generated writes preserve it" property over the entity's writers | | Event with a Workflow | consumer: h.consumerRegistered(event, workflow) | | Integration with webhook | pitfall.webhook-signature (signed body accepted, tampered body rejected; custom scheme: tampered only), pitfall.raw-body, pitfall.idempotency |

Declared and observe modes get different assertion columns (412 + Contract id vs non-2xx + trace record; 401/403 + Policy id vs status in {401, 403}; trace emit phase vs spy calls). Guards get no tests. Anything the spec marks as non-derivable (guard policies, relation cycles, Json/Bytes/Unsupported fields, list-relation where keys, db.countWhere fixtures, refs the generator cannot control) becomes it.todo(reason) and is listed in PlannedSuite.todos.

Fixture synthesis

For a predicate over model with a flat where, the emitted seed function builds the satisfying row (refs from the generated input and the fixture's actor, literals as given), draws every other required field with fast-check per Prisma type, creates required to-one parents first (depth <= 3, FK scalar found by the <relation>Id convention, ensureRow when the FK value is pinned), and in falsify mode alters the first where key (eq -> different value, in -> not-in sample, not -> the excluded value, range -> out of range). @unique columns draw nonce-suffixed values instead of retrying.

The harness the generated tests import

src/harness-api.ts is the surface @averri/contracts must export (createTestHarness, AverriTestHarness, PhaseLike, TraceLike, PrismaModelLike). The typecheck test maps @averri/contracts onto this file and runs tsc with noUnusedLocals/noUnusedParameters over the emitted files.

Tests

npx vitest run packages/testgen — unit tests per module, property tests (emitted arbitraries are instantiated with real fast-check and checked against an independent clause evaluator), golden files in test/golden/ (UPDATE_GOLDEN=1 to accept), determinism under node/edge permutation, and the emitted-code typecheck.