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

@adaptive-tests/typescript

v0.3.0

Published

TypeScript extension for adaptive-tests - AI-ready testing infrastructure that survives refactors.

Readme

@adaptive-tests/typescript

AI-ready testing infrastructure for TypeScript projects

Installation

# Install the meta package + TypeScript companion
npm install adaptive-tests @adaptive-tests/typescript

# Peer dependencies (if not already installed)
npm install --save-dev typescript ts-node

Quick Start

Basic TypeScript Discovery

import { discover } from 'adaptive-tests';
import { getTypeScriptDiscoveryEngine } from 'adaptive-tests-typescript';

describe('UserService', () => {
  let UserService: any;

  beforeAll(async () => {
    // TypeScript-aware discovery
    const engine = getTypeScriptDiscoveryEngine('./src');
    UserService = await engine.discoverTarget({
      name: 'UserService',
      type: 'class',
      methods: ['findById', 'create'],
      interfaces: ['IUserService']  // TypeScript-specific
    });
  });

  test('finds user by ID', async () => {
    const service = new UserService();
    const user = await service.findById(1);
    expect(user).toBeDefined();
  });
});

Interface Discovery

import { discoverInterface } from 'adaptive-tests-typescript';

describe('Payment interfaces', () => {
  test('discovers payment gateway interface', async () => {
    const IPaymentGateway = await discoverInterface({
      name: 'IPaymentGateway',
      methods: ['processPayment', 'refund'],
      properties: ['supportedCurrencies']
    });

    // Test implementations of the interface
    const StripeGateway = await discover({
      name: 'StripeGateway',
      implements: ['IPaymentGateway']
    });

    expect(StripeGateway).toBeDefined();
  });
});

Generic Type Discovery

describe('Generic classes', () => {
  test('discovers repository with generic types', async () => {
    const UserRepository = await discover({
      name: 'Repository',
      type: 'class',
      generics: ['User'],  // Repository<User>
      methods: ['findAll', 'save']
    });

    const repo = new UserRepository();
    expect(repo.findAll).toBeDefined();
  });
});

TypeScript-Specific Features

Type-Aware Discovery

The TypeScript engine understands:

  • Interfaces: interface IUserService { ... }
  • Abstract classes: abstract class BaseService { ... }
  • Generic types: class Repository<T> { ... }
  • Decorators: @Injectable() class UserService { ... }
  • Enums: enum UserRole { Admin, User }
  • Type aliases: type UserId = string;

Advanced Signatures

// Interface discovery
await discover({
  name: 'IUserService',
  type: 'interface',
  methods: ['findById', 'create'],
  properties: ['cache']
});

// Abstract class discovery
await discover({
  name: 'BaseController',
  type: 'abstract',
  methods: ['authorize', 'validate']
});

// Decorator-based discovery
await discover({
  name: 'UserController',
  type: 'class',
  decorators: ['@Controller', '@Injectable'],
  methods: ['getUser', 'createUser']
});

// Generic class discovery
await discover({
  name: 'Repository',
  type: 'class',
  generics: ['T'],
  methods: ['find', 'save', 'delete']
});

TypeScript Configuration

Create adaptive-tests.config.ts:

import { Config } from 'adaptive-tests-typescript';

const config: Config = {
  typescript: {
    // tsconfig.json path
    configFile: './tsconfig.json',

    // Parse decorators
    experimentalDecorators: true,

    // Include .tsx files
    jsx: true,

    // Strict type checking
    strict: true
  },

  discovery: {
    // TypeScript file patterns
    include: ['src/**/*.ts', 'src/**/*.tsx'],

    // Exclude compiled output
    exclude: ['dist/**', 'build/**', '**/*.d.ts']
  }
};

export default config;

Examples

React Component (TypeScript)

// src/components/UserCard.tsx
interface Props {
  user: User;
  onClick?: () => void;
}

export const UserCard: React.FC<Props> = ({ user, onClick }) => {
  return <div onClick={onClick}>{user.name}</div>;
};
// tests/UserCard.adaptive.test.tsx
import { discover } from 'adaptive-tests';
import { render } from '@testing-library/react';

describe('UserCard Component', () => {
  let UserCard: any;

  beforeAll(async () => {
    UserCard = await discover({
      name: 'UserCard',
      type: 'function',
      exports: 'named',
      frameworks: ['react']  // Framework hint
    });
  });

  test('renders user name', () => {
    const user = { name: 'John Doe' };
    const { getByText } = render(<UserCard user={user} />);
    expect(getByText('John Doe')).toBeInTheDocument();
  });
});

Service with Dependency Injection

// src/services/UserService.ts
@Injectable()
export class UserService implements IUserService {
  constructor(
    private repository: UserRepository,
    private cache: CacheService
  ) {}

  async findById(id: string): Promise<User> {
    // Implementation
  }
}
// tests/UserService.adaptive.test.ts
describe('UserService', () => {
  test('discovers service with dependencies', async () => {
    const UserService = await discover({
      name: 'UserService',
      type: 'class',
      decorators: ['Injectable'],
      implements: ['IUserService'],
      dependencies: ['UserRepository', 'CacheService']
    });

    expect(UserService).toBeDefined();
  });
});

Framework Integration

Jest with TypeScript

// jest.config.js
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  setupFilesAfterEnv: ['adaptive-tests-typescript/setup'],
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
  transform: {
    '^.+\\.(ts|tsx)$': 'ts-jest'
  }
};

Vitest with TypeScript

// vitest.config.ts
import { defineConfig } from 'vitest/config';

export default defineConfig({
  test: {
    environment: 'node',
    setupFiles: ['adaptive-tests-typescript/setup']
  }
});

API Reference

getTypeScriptDiscoveryEngine(rootPath?)

Creates a TypeScript-aware discovery engine:

import { getTypeScriptDiscoveryEngine } from 'adaptive-tests-typescript';

const engine = getTypeScriptDiscoveryEngine('./src');
const UserService = await engine.discoverTarget('UserService');

discoverInterface(signature, rootPath?)

Discovers TypeScript interfaces:

import { discoverInterface } from 'adaptive-tests-typescript';

const IUserService = await discoverInterface({
  name: 'IUserService',
  methods: ['findById', 'create']
});

discoverType(signature, rootPath?)

Discovers type aliases and complex types:

import { discoverType } from 'adaptive-tests-typescript';

const UserId = await discoverType({
  name: 'UserId',
  type: 'alias'
});

Migration from JavaScript

Existing JavaScript Tests

If you have existing adaptive tests in JavaScript, they'll continue working. To add TypeScript support:

  1. Install the TypeScript extension
  2. Update imports to use TypeScript-aware discovery
  3. Add TypeScript-specific signatures as needed

Example Migration

Before (JavaScript):

const UserService = await discover('UserService');

After (TypeScript):

const UserService = await discover({
  name: 'UserService',
  type: 'class',
  implements: ['IUserService'],  // Now type-aware!
  decorators: ['Injectable']
});

Troubleshooting

Common Issues

TypeScript compilation errors

# Ensure ts-node is installed and configured
npm install --save-dev ts-node

Interface discovery fails

// Use more specific signatures
const IUserService = await discoverInterface({
  name: 'IUserService',
  methods: ['findById'],
  location: './src/interfaces'  // Narrow the search
});

Generic type issues

// Be explicit about generic constraints
const Repository = await discover({
  name: 'Repository',
  generics: ['T extends BaseEntity'],
  methods: ['save', 'find']
});

Development

Building from Source

git clone https://github.com/anon57396/adaptive-tests.git
cd adaptive-tests/languages/typescript
npm install
npm run build
npm test

Contributing

We welcome TypeScript-specific contributions! See CONTRIBUTING.md for guidelines.


License

MIT - See LICENSE for details.


Ready to make your TypeScript tests refactoring-proof?

npm install adaptive-tests adaptive-tests-typescript

Start with the Quick Start guide above!