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

@suites/codemod

v0.1.0

Published

Code transformation tool for the Suites testing framework

Readme

@suites/codemod

npm version License: MIT

Code transformation toolkit for the Suites testing framework

Automated code transformations for Suites projects. Built on jscodeshift with intelligent AST-based transformations, built-in validation, and TypeScript-first support.

Usage

npx @suites/codemod <codemod> <source> [options]

Example:

npx @suites/codemod automock/2/to-suites-v3 src/**/*.spec.ts

Run with --dry or -d to preview changes without modifying files.

Available Codemods

  • automock/2/to-suites-v3 - Migrate test files from Automock v2 to Suites v3 testing framework

Example

Before (Automock)

import { TestBed } from '@automock/jest';

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

  beforeAll(() => {
    const { unit } = TestBed.create(UserService)
      .mock(UserRepository)
      .using({ findById: jest.fn() })
      .compile();
    service = unit;
  });
});

After (Suites)

import { TestBed } from '@suites/unit';

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

  beforeAll(async () => {
    const { unit } = await TestBed.solitary(UserService)
      .mock(UserRepository)
      .final({ findById: jest.fn() })
      .compile();
    service = unit;
  });
});

CLI Reference

Arguments

| Argument | Description | Default | | --------- | ----------------------------------------------------------------------- | ------- | | codemod | Codemod slug to run. See available transforms below. | - | | source | Path to source files or directory to transform including glob patterns. | . |

Options

| Option | Description | Default | | ------------------- | --------------------------------------------------------- | ------- | | -v, --version | Output the current version | - | | -d, --dry | Dry run (no changes are made to files) | false | | -f, --force | Bypass Git safety checks and forcibly run codemods | false | | -p, --print | Print transformed files to stdout, useful for development | false | | --verbose | Show more information about the transform process | false | | --parser <parser> | Parser to use: tsx, ts, babel | tsx | | -h, --help | Display help message | - |

Examples:

# Preview changes (dry run)
npx @suites/codemod automock/2/to-suites-v3 src --dry

# Print output to stdout
npx @suites/codemod automock/2/to-suites-v3 src/file.ts -p

# Verbose output
npx @suites/codemod automock/2/to-suites-v3 src --verbose

# Use different parser
npx @suites/codemod automock/2/to-suites-v3 src --parser babel

Transform Details

automock/2/to-suites-v3

Intelligently migrates Automock v2 test files to Suites v3 framework.

What it transforms:

  • Import statements: @automock/jest -> @suites/unit
  • TestBed API: TestBed.create() -> TestBed.solitary().compile()
  • Mock configuration: .using() -> .impl() or .final()
  • Type annotations: jest.Mocked<T> -> Mocked<T> from @suites/unit
  • Async/await: Adds async/await to test hooks as needed
  • Mock retrieval: Intelligently selects .impl() vs .final() strategy
  • Jest globals: Preserves jest imports where needed
  • Type casts: Removes obsolete type assertions

Mock Strategy Selection:

The codemod automatically chooses between .impl() and .final():

  • .impl() - Used when mocks are retrieved via unitRef.get() and need runtime manipulation (spy assertions, dynamic mock configuration)
  • .final() - Used when mocks are provided as final implementations without retrieval

Validation:

Built-in validation ensures:

  • No @automock imports remain
  • TestBed.create() is converted to TestBed.solitary()
  • .compile() is called with proper await
  • Mock strategies are correctly applied
  • Retrieved mocks use .impl() strategy

Requirements

  • Node.js: ^16.10.0 || ^18.12.0 || >=20.0.0
  • Project Type: TypeScript or JavaScript
  • Git: Clean working directory recommended (bypass with --force)

Troubleshooting

"Working directory is not clean"

  • Commit your changes or use --force to bypass

"No files found"

  • Check your source path and ensure it contains .ts or .tsx files

Parser errors

  • Try the babel parser: --parser babel

Validation failed

  • Run with --verbose for detailed logs
  • Review validation errors in the output
  • Fix the issues reported by validators

For more help, see troubleshooting guide or open an issue.

How It Works

The codemod uses jscodeshift to:

  1. Parse TypeScript/JavaScript into an Abstract Syntax Tree (AST)
  2. Apply intelligent transformations (imports, TestBed API, mocks, types)
  3. Validate the transformed code
  4. Output the result

TypeScript Support: First-class support with fallback parser for complex syntax (generics, type guards, decorators, JSX/TSX).

Architecture

This codemod follows the Codemod Registry pattern used by React, Next.js, and other major frameworks:

Transform Naming: <framework>/<version>/<transform>

  • automock/2/to-suites-v3 - Current migration
  • automock/3/to-suites-v4 - Future migrations
  • Supports multiple transforms per version
  • Extensible to other frameworks (e.g., jest/28/to-v29)

Directory Structure:

src/transforms/
  automock/              # Framework namespace
    2/                   # Source version
      to-suites-v3.ts    # Migration transform
    3/                   # Future: next version
      to-suites-v4.ts

Design Benefits:

  • No default transform - explicit selection prevents mistakes
  • Version-based organization supports migration chains
  • Framework namespacing allows multi-framework support
  • Clear source → target versioning

Contributing

Contributions welcome! To contribute:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes and add tests
  4. Run tests: npm test and linter: npm run lint
  5. Commit: git commit -m "feat: add feature"
  6. Push and open a Pull Request

Adding New Transforms

  1. Create transform directory: src/transforms/<framework>/<version>/<transform-name>.ts

  2. Export a default function that follows jscodeshift's transform signature:

    import type { FileInfo, API, Options } from 'jscodeshift';
    import { transform } from '../../../transform';
    
    export default transform;

    Or implement your own transform function:

    import type { FileInfo, API, Options } from 'jscodeshift';
    
    export default function transform(
      fileInfo: FileInfo,
      api: API,
      options: Options
    ): string | null | undefined {
      // Your transform logic here
      return transformedCode;
    }
  3. Register in src/transforms/index.ts:

    {
      name: 'framework/version/transform-name',
      description: 'Description of what it does',
      path: './transforms/framework/version/transform-name',
    }
  4. Add test fixtures in fixtures/

  5. Add integration tests in test/integration/

  6. Update this README

Example:

// src/transforms/automock/3/to-suites-v4.ts
import { transform } from '../../../transform';

export default transform;

Project Structure

src/
  analyzers/        # Code analysis utilities
  transforms/       # Transform implementations
    automock/       # Framework namespace
      2/            # Version-specific transforms
        to-suites-v3.ts
    index.ts        # Transform registry
  validators/       # Post-transform validation
  utils/            # Shared utilities
  cli.ts            # CLI interface
  runner.ts         # Transform runner
  transform.ts      # Main transform logic

test/
  integration/      # Integration tests
  transforms/       # Transform unit tests
  fixtures/         # Test fixtures (before/after)

License

MIT (c) Omer Morad

Links

Related Projects


Need help? Open an issue on GitHub or check the Suites documentation.