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

scopetest-cli

v0.1.5

Published

Smart test selector - run only tests affected by code changes

Readme

scopetest

npm version npm downloads license

Run only the tests that matter. A fast, dependency-aware test selector for JS/TS monorepos.

# Run affected tests with one command
scopetest affected -x "jest --runTestsByPath {} --colors"

Why?

In large monorepos, running all tests is slow. scopetest analyzes your dependency graph and runs only tests affected by your changes—cutting CI time from minutes to seconds.

Install

npm install -g scopetest-cli

Usage

# Find affected tests
scopetest affected --base main

# Execute tests directly
scopetest affected -x "jest --runTestsByPath {}"
scopetest affected -x "vitest run {}"

# Get affected source files instead
scopetest affected --sources

# Different output formats
scopetest affected -f list    # newline-separated
scopetest affected -f json    # full stats

# Changes since a specific commit
scopetest affected --since HEAD~5

# Stop on first failure
scopetest affected -x "jest --runTestsByPath {}" --fail-fast

# Run all tests if too many affected (blast radius protection)
scopetest affected -x "jest --runTestsByPath {}" --threshold 100

Commands

affected - Find tests affected by changes

Options:
  -b, --base <REF>       Git ref to compare against (branch, commit, tag)
      --since <REF>      Find changes since this commit (commit..HEAD range)
  -f, --format <FMT>     Output: paths, list, json [default: paths]
  -x, --exec <CMD>       Execute command with {} replaced by affected files
      --fail-fast        Stop on first test failure (only with --exec)
      --threshold <N>    If affected tests exceed N, use all tests instead
      --sources          Output affected source files instead of tests
      --no-cache         Skip cache, force rebuild
  -r, --root <PATH>      Project root directory

why - Explain why a test is affected

# See why a specific test is in the affected set
scopetest why src/utils/calc.spec.ts

# Show all dependency paths, not just shortest
scopetest why src/utils/calc.spec.ts --all
Options:
  <TEST>                 The test file to explain
  -b, --base <REF>       Git ref to compare against
      --since <REF>      Find changes since this commit
      --all              Show all paths, not just the shortest
  -r, --root <PATH>      Project root directory
      --no-cache         Skip cache, force rebuild

build - Rebuild dependency graph cache

Options:
  -r, --root <PATH>    Project root directory

Output Formats

| Format | Description | Example | |--------|-------------|---------| | paths | Space-separated (default) | src/a.spec.ts src/b.spec.ts | | list | Newline-separated | src/a.spec.tssrc/b.spec.ts | | json | Full stats | {"tests": [...], "stats": {...}} |

Aliases: jest and vitest both map to paths.

Configuration

Create .scopetestrc.json:

{
  "testPatterns": ["**/*.spec.ts", "**/*.test.ts"],
  "ignorePatterns": ["**/node_modules/**", "**/dist/**"],
  "extensions": [".ts", ".tsx", ".js", ".jsx"]
}

CI Examples

GitHub Actions

- name: Run affected tests
  run: npx scopetest-cli affected -b origin/main -x "jest --runTestsByPath {} --colors"

# With blast radius protection (threshold exceeded = run all tests)
- name: Run affected tests (with threshold)
  run: npx scopetest-cli affected -b origin/main -x "jest --runTestsByPath {}" --threshold 500

Jenkins

npx scopetest-cli affected -b origin/master -x "npx jest --runTestsByPath {} --colors"

Manual (pipe style)

jest --runTestsByPath $(scopetest affected -b main)

How It Works

  1. Parses all JS/TS files using oxc
  2. Builds a dependency graph with petgraph
  3. Gets changed files from git diff
  4. Traverses graph to find all affected files
  5. Filters to test files only

Performance

On a 12,500+ file monorepo:

  • Initial build: ~20-30s
  • Cached: ~200ms

Supported Imports

  • ES6: import x from 'y'
  • Dynamic: import('path')
  • CommonJS: require('path')
  • Re-exports: export * from 'y'
  • TypeScript path aliases
  • Workspace packages

License

MIT