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

@luckystack/test-runner

v0.8.3

Published

Generated-type-driven test layers for LuckyStack: contract smoke (Zod-valid input), auth enforcement, rate-limit, and crash-resistance fuzz. Walks every endpoint via the generated apiMethodMap.

Readme

@luckystack/test-runner

Generated-type-driven test layers for LuckyStack. Walks every endpoint in your apiMethodMap.generated.ts and runs four progressive test layers: contract smoke (Zod-valid input), auth enforcement, rate-limit, and crash-resistance fuzz.

Install

npm install --save-dev @luckystack/test-runner zod

Quickstart

Run all four layers against a running server:

import {
  runAllTests,
  resolveTestBaseUrl,
  logRunAllSummary,
} from '@luckystack/test-runner';
import { apiInputSchemas } from './src/_sockets/apiInputSchemas.generated';
import { apiMetaMap, apiMethodMap } from './src/_sockets/apiTypes.generated';
import { ports } from './config.ports';

const baseUrl = resolveTestBaseUrl({ fallbackUrl: `http://localhost:${ports.backend}` });
const summary = await runAllTests({
  apiMethodMap,
  apiMetaMap,
  apiInputSchemas,
  baseUrl,
  // Loaded only after .env/.env.local. If config.secretManager.url is set,
  // pointers are resolved in THIS process before Layer-5 tests touch Prisma.
  loadProjectConfig: async () => (await import('./config')).default,
});
logRunAllSummary(summary);

Each layer is independently runnable — you can skip the ones that don't apply or rearrange them.

runAllTests always loads the normal env-file layers and requires loadProjectConfig as above, even in projects that currently use only local env values. A configured resolver is loaded dynamically and runs in fail-fast remote mode before custom test modules are imported. Direct runCustomTests callers must pass the same callback. Both public paths reject a missing loader so a later secret-manager rollout cannot silently expose pointer values. This matters because the live server resolving its own DATABASE_URL does not mutate the separate test process.

Layers

| Layer | What it asserts | | --- | --- | | Contract | A Zod-valid input payload reaches main and returns { status: 'success' } (or a typed failure status). Catches schema/route mismatches. | | Auth enforcement | Endpoints flagged auth.login: true reject unauthenticated requests with the framework's standard 401 shape. | | Rate limit | Endpoints with rateLimit: <N> reject the (N + 1)th request inside the window. | | Fuzz | Bad/random inputs never crash the server (still returns a typed error response, never 500 with a stack). |

The fuzz layer is intentionally exhaustive and slow — wire it into nightly CI rather than every PR.

Server hooks it depends on

  • /_test/reset endpoint — served by @luckystack/server outside production (gated on NODE_ENV !== 'production' and an optional TEST_RESET_TOKEN). Used by resetServerState to clear DB + Redis between layers. Make sure TEST_RESET_TOKEN is set in any non-prod environment that is reachable over the network.
  • apiMethodMap.generated.ts — produced by @luckystack/devkit from your _api/* files. Defaults are read via getApiMethodMapPath() from @luckystack/core.

Public API

| Export | Purpose | | --- | --- | | walkEndpoints(apiMethodMap) | Returns EndpointDescriptor[] from the generated map. | | runContractCheck(input) / runContractTests(input) | Single endpoint / full sweep. | | runAuthEnforcementCheck(input) / runAuthEnforcementTests(input) | Auth layer. | | runRateLimitCheck(input) / runRateLimitTests(input) | Rate-limit layer. | | runFuzzCheck(input) / runFuzzTests(input) | Fuzz layer. | | resetServerState(input) | POST to /_test/reset. | | resolveTestEnvironment({ loadProjectConfig? }) | Load env layers and optional secret-manager pointers for the test process; runAllTests calls it automatically. | | sampleSchemaInput(schema) | Generate a Zod-valid sample payload. | | logContractResult / logContractSummary | Pretty-printers. |

Types: EndpointDescriptor, HttpMethod, ContractCheckResult, RunContractSummary, plus per-layer input types.

Related architecture docs

Dependencies

  • Required peers: zod@^4.0.0, socket.io-client@^4.8.0.
  • Optional peers: @luckystack/login, @luckystack/secret-manager (loaded only for their corresponding features).

License

MIT — see LICENSE.