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

@qadi/testing

v0.11.0

Published

Fixtures, deterministic layers and recording resolvers for @qadi/core

Readme

@qadi/testing

Fixtures and deterministic layers for testing against @qadi/core.

pnpm add -D @qadi/testing effect

Deterministic by construction

Evaluation identifiers come from a service, so qadiTestLayer wires a sequential generator and a decision's id is eval-1, eval-2, … rather than a uuid. Durations come from Clock, so they are reproducible under TestClock — which @effect/vitest's it.effect already provides.

import { qadiTestLayer, subjectWith } from "@qadi/testing";

const layer = qadiTestLayer(subjectWith({ permissions: ["doc:read"] }), {
  attributes: { clearance: 5 },
});

Defaults fail closed

Every default here denies, so a test that forgets to grant something sees a denial rather than an accidental allow. That is the same posture the library takes in production, which is what makes a test meaningful.

Overriding a port

Each data option (attributes, relationships, history, signatures) becomes that port's @qadi/core fixture. To wire any port directly, pass it under ports, keyed by port name; an entry there wins over the matching data option, and every port you do not name stays at its fail-closed default.

Scripted and recording ports

The doubles are @qadi/core's, derived from each port's description, so they work for every port alike. scriptedPort answers, fails with the port's own error, dies or throws per request; recordingPort wraps a real port and keeps the requests it saw. Both return { layer, calls }, so a test can assert not only the decision but the work done to reach it — which is how short-circuiting is verified.

import {
  PortReply,
  anyOf,
  attributeResolverFromRecord,
  attributeResolverPort,
  evaluate,
  gte,
  hasAttribute,
  recordingPort,
  scriptedPort,
} from "@qadi/core";
import { qadiTestLayer, subjectWith } from "@qadi/testing";
import * as Effect from "effect/Effect";

// A store that is down: every lookup fails with AttributeResolveError.
const down = scriptedPort(attributeResolverPort, () => PortReply.fail("down"));

// A real table, recorded.
const table = recordingPort(attributeResolverPort, attributeResolverFromRecord({ tier: 5 }));

const program = evaluate(anyOf([hasAttribute("tier", gte(1)), hasAttribute("other", gte(1))])).pipe(
  Effect.provide(qadiTestLayer(subjectWith({}), { ports: { AttributeResolver: table.layer } })),
);
// After running `program`, `table.calls` is `[["test-subject", "tier"]]`:
// `anyOf` stopped at the first allow. `down.layer` in the same slot would make
// `program` fail rather than deny.
export { down, program };

License

MIT