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

@heroku-cli/test-utils

v0.2.0

Published

Test utilities for Heroku CLI

Readme

@heroku-cli/test-utils

A collection of test utilities for the Heroku CLI, designed to make testing CLI commands easier and more consistent. Built with ESM support and TypeScript.

Overview

This package provides utilities to help test Heroku CLI commands, including:

  • Command execution helpers with output capture
  • Output expectation utilities
  • Test initialization helpers
  • Shared ESLint configuration

Installation

npm install --save-dev @heroku-cli/test-utils

Requirements

  • Node.js >= 20
  • TypeScript >= 5.4.0
  • ESM (ES Modules) support
  • Testing frameworks: Mocha, Chai, and Sinon

ESLint Configuration

This package provides a shareable ESLint 9 flat config that extends oclif's base configuration with Heroku-specific rules.

Setup

  1. Install the required peer dependencies:
npm install --save-dev eslint@^9 eslint-config-oclif@^6
  1. Create eslint.config.js in your project root:
import herokuConfig from '@heroku-cli/test-utils/eslint-config'

export default [
  ...herokuConfig,
  // Your additional config here
]

What's Included

The configuration includes:

  • oclif base rules - TypeScript, Node.js, and CLI best practices
  • Mocha support - Test framework rules
  • Import plugin - Module import/export rules
  • Heroku-specific rules:
    • camelcase: 'warn' - Allow snake_case for API compatibility
    • no-console: 'off' - Allow console for CLI output
    • Custom indent rules for readability
  • Test file overrides - Special rules for test files
  • Ignore patterns - Excludes dist/ directory

Usage

Running Commands

The runCommand helper runs oclif commands and captures their output:

import { runCommand } from '@heroku-cli/test-utils'
import { MyCommand } from '../src/commands/my-command.js'

describe('MyCommand', () => {
  it('should run successfully', async () => {
    const { result, stdout, stderr } = await runCommand(
      MyCommand,
      ['--flag', 'value'],
      { root: __dirname }
    )

    expect(result).to.deep.equal({ success: true })
    expect(stdout).to.include('Expected output')
  })

  it('should handle errors', async () => {
    const { error } = await runCommand(MyCommand, ['--invalid'])
    expect(error).to.exist
    expect(error.message).to.include('Invalid flag')
  })
})

Return Value

runCommand returns an object with:

  • result - The command's return value (if successful)
  • error - Error object (if command failed)
  • stdout - Captured standard output
  • stderr - Captured standard error

Test Configuration

Use the test helper functions to set up your test environment:

import { getConfig, getHerokuAPI } from '@heroku-cli/test-utils'

// Get oclif configuration
const config = await getConfig({ root: '/path/to/project' })

// Get Heroku API client
const api = await getHerokuAPI({ root: '/path/to/project' })

Expecting Output

import expectOutput from '@heroku-cli/test-utils'

// Validate command output patterns
expectOutput(stdout, /Expected pattern/)

Initializing Tests

import { setupTest } from '@heroku-cli/test-utils'

beforeEach(() => {
  setupTest()
})

Development

Building

npm run build

Linting

npm run lint

Testing

npm test

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

This project is licensed under the ISC License - see the LICENSE file for details.