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

ai-testcase-generator

v0.1.0

Published

Generate Playwright or Vitest API test skeletons from an OpenAPI spec — offline, template-driven, no API key required.

Readme

ai-testcase-generator

Generate Playwright or Vitest API test skeletons from an OpenAPI spec — offline, template-driven, no API key required.

CI npm version License: MIT Node

Writing the first draft of an API test suite is repetitive: read the spec, enumerate every endpoint, stub a happy-path test, then stub the obvious negative cases (missing required params, missing body). ai-testcase-generator (atg) does that mechanical first pass for you — deterministically, in milliseconds, with no network calls and no LLM credentials.

You get a runnable skeleton with TODOs where judgement is needed; you fill in the real data and assertions. It is a starting point, not an oracle — and it is honest about that.

Why "AI" with no API key? The v0.1 engine is a deterministic, rule-based generator — it always runs offline and is fully reproducible. An optional LLM mode (to suggest realistic test data and richer assertions) is on the roadmap as an enhancement, never a requirement. The core tool will always work without any key.

Features

  • OpenAPI 3 in, tests out — reads JSON or YAML specs.
  • Two formats--format playwright (API request fixture) or --format vitest (fetch).
  • Positive + negative cases — a happy path per operation, plus a negative case for every required parameter and required body.
  • list command — quickly enumerate the operations in a spec.
  • Offline & deterministic — same spec in, same tests out. No network, no key.
  • One small dependency (yaml); everything else is standard library.

Installation

# Global CLI
npm install -g ai-testcase-generator

# Or run once
npx ai-testcase-generator list examples/petstore.yaml

Requires Node.js >= 18.

Usage

atg <command> [options]

Commands
  list      <spec>            List the operations found in the spec
  generate  <spec>            Generate test skeletons for every operation

Options
  --format <playwright|vitest>   Output format (default: playwright)
  --out <file>                   Write to a file instead of stdout
  -h, --help                     Show help
  -v, --version                  Show version

Examples

List operations:

$ atg list examples/petstore.yaml
GET    /pets  (listPets)
POST   /pets  (createPet)
GET    /pets/{petId}  (getPet)

3 operation(s).

Generate Playwright tests:

$ atg generate examples/petstore.yaml
import { test, expect } from '@playwright/test';

const BASE_URL = process.env.BASE_URL ?? 'http://localhost:3000';

test.describe('GET /pets/{petId}', () => {
    test('getPet returns success for a valid request', async ({ request }) => {
        // Send a well-formed request with all required inputs.
        // TODO: fill in path/query params, headers, and body as needed
        const response = await request.get(`${BASE_URL}/pets/{petId}`);
        expect(response.status()).toBeGreaterThanOrEqual(200);
        expect(response.status()).toBeLessThanOrEqual(299);
    });

    test('getPet rejects a request missing required path parameter "petId"', async ({ request }) => {
        // Omit the required path parameter "petId".
        // TODO: fill in path/query params, headers, and body as needed
        const response = await request.get(`${BASE_URL}/pets/{petId}`);
        expect(response.status()).toBeGreaterThanOrEqual(400);
        expect(response.status()).toBeLessThanOrEqual(499);
    });
});

Write Vitest tests to a file:

$ atg generate examples/petstore.yaml --format vitest --out tests/api.spec.ts

Use it as a library:

import { parseSpec, extractOperations, deriveCases, renderSuite } from 'ai-testcase-generator';

const ops = extractOperations(parseSpec(specText));
const code = renderSuite(ops.map((op) => ({ op, cases: deriveCases(op) })), 'playwright');

Roadmap

  • [ ] v0.2 — generate realistic request bodies from the schema (example/enum aware)
  • [ ] v0.3 — boundary cases for typed/constrained parameters (min/max, length, enum)
  • [ ] v0.4--out <dir> mode: one test file per tag/resource
  • [ ] v0.5 — optional --llm enhancement to suggest test data and assertions (key-gated, never required)
  • [ ] v1.0 — stable library API + Postman collection input

Contributing

See CONTRIBUTING.md. The whole pipeline is pure functions (parseSpec → extractOperations → deriveCases → renderSuite), so contributions come with fast, deterministic unit tests.

git clone https://github.com/fkhb90/ai-testcase-generator.git
cd ai-testcase-generator
npm install
npm test
npm run dev -- generate examples/petstore.yaml

Related projects

License

MIT © fkhb90