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

@craftapit/typedapi-tester-addon

v0.1.2

Published

TypedAPI testing capabilities for Craft-a-Tester

Downloads

17

Readme

@craftapit/typedapi-tester-addon

TypedAPI testing capabilities for Craft-a-Tester, enabling contract validation, request/response validation, and mock generation.

Features

  • TypedAPI contract validation
  • Request type validation
  • Response type validation
  • Request validation against contracts
  • Response validation against contracts
  • Mock request generation
  • Mock response generation
  • TypeScript type generation from contracts
  • Property and type checking

Installation

This package is designed to work as part of the craftacoder monorepo using npm workspaces:

# From the root of the monorepo
npm install -w @craftapit/typedapi-tester-addon

Or install it directly:

npm install @craftapit/typedapi-tester-addon

Usage

Basic Usage

import { TypedAPIAdapter, TypedAPIAddon } from '@craftapit/typedapi-tester-addon';

// Create and initialize the TypedAPI adapter
const adapter = new TypedAPIAdapter({
  contractsBasePath: './contracts',
  validation: {
    strictMode: true
  }
});

await adapter.initialize();

// Validate a contract
const result = await adapter.validateContract('user.get.contracts.ts');
console.log(result);

Integration with Craft-a-Tester

import { TestExecutor, CapabilityRegistry } from '@craftapit/tester';
import { TypedAPIAddon } from '@craftapit/typedapi-tester-addon';

// Create and initialize the test executor
const executor = new TestExecutor();

// Create the registry
const registry = new CapabilityRegistry();

// Create and register the TypedAPI addon
const typedAPIAddon = new TypedAPIAddon({
  contractsBasePath: './contracts'
});
typedAPIAddon.register(registry);

// Execute tests using the registry
const results = await executor.executeTests('tests/contract-tests.md', {
  registry
});

Using with LLM-based Testing

The TypedAPI addon can be used with Craft-a-Tester's LLM-based testing capabilities:

import { TestExecutor, CapabilityRegistry, OllamaAdapter } from 'craft-a-tester';
import { TypedAPIAddon } from '@craftapit/typedapi-tester-addon';

// Create and initialize the test executor
const executor = new TestExecutor();

// Create the registry
const registry = new CapabilityRegistry();

// Set up LLM adapter
const llmAdapter = new OllamaAdapter({
  baseUrl: 'http://localhost:11434',
  model: 'llama3:8b',
  contextSize: 8192
});
await llmAdapter.initialize();
registry.setLLMAdapter(llmAdapter);

// Register the TypedAPI addon
const typedAPIAddon = new TypedAPIAddon({
  contractsBasePath: './contracts'
});
typedAPIAddon.register(registry);

// Execute tests with LLM-based capability resolution
const results = await executor.executeTests('tests/contract-tests.md', {
  registry
});

Configuration Options

The TypedAPIAdapter supports the following configuration options:

{
  // Base path for contract files
  contractsBasePath?: string;
  
  // Validation options
  validation?: {
    // Whether to use strict mode for validation
    strictMode?: boolean;
    
    // Whether to allow extra properties in requests/responses
    allowExtraProperties?: boolean;
    
    // Whether to validate types
    validateTypes?: boolean;
    
    // Whether to validate path parameters
    validatePaths?: boolean;
  };
  
  // Mock data generation options
  mock?: {
    // Whether to generate realistic data for mocks
    generateRealisticData?: boolean;
    
    // Locale for generated data
    locale?: string;
    
    // Seed for consistent mock generation
    seed?: number;
    
    // Custom generators for specific field types
    customGenerators?: Record<string, () => any>;
  };
}

Using the CLI

You can use the craft-a-tester CLI to run TypedAPI tests:

# Configuration file (craft-a-tester.json)
{
  "llm": {
    "provider": "ollama",
    "baseUrl": "http://localhost:11434",
    "model": "phi4:14b-fp16",
    "contextSize": 16384,
    "dynamicContextSizing": true
  }
}

# Run tests with the CLI
craft-a-tester run-all tests/stories --recursive --config craft-a-tester.json

Running the Examples

The package includes several examples:

# Run the integration example
npm run run:example

# Test contract validation
npm run test:contract

# Test TypeScript integration
npm run test:typescript

# Run tests with CLI
npm run test:cli

Testing in the Monorepo

When working in the monorepo, use the workspace commands:

# Build all packages (from monorepo root)
npm run build:all

# Run TypedAPI tests (from monorepo root)
npm run test:typedapi-addon

# Run the integration example
npm run run:example -w @craftapit/typedapi-tester-addon

# Test with Ollama
npm run test:ollama -w @craftapit/typedapi-tester-addon

# Run tests with CLI
npm run test:cli -w @craftapit/typedapi-tester-addon

License

MIT