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

@mathonsunday/useless-test-detector

v0.1.0

Published

Detects test files that don't actually test real implementations

Readme

Useless Test Detector

Detects test files that don't actually test real implementations.

Based on real-world experience cleaning up test suites where tests create mock objects, assert on hardcoded values, or test JavaScript/TypeScript built-ins instead of actual application logic.

Installation

npm install --save-dev @mathonsunday/useless-test-detector

Or run directly with npx:

npx @mathonsunday/useless-test-detector

Usage

CLI

# Scan default directories (src, api)
useless-tests

# Scan custom directories
useless-tests --dirs src,tests,lib

# Only show high confidence results
useless-tests --min-confidence high

# Output as JSON
useless-tests --json > report.json

Programmatic API

import { detectUselessTests } from '@mathonsunday/useless-test-detector';

const results = detectUselessTests({
  directories: ['src', 'api'],
  minConfidence: 'medium',
});

for (const test of results) {
  console.log(test.file, test.confidence, test.reasons);
}

What It Detects

The tool looks for these anti-patterns:

  1. Inline implementations: Tests that define their own EventBuffer, Parser, etc. instead of importing the real one
  2. Type-only tests: Tests that only verify TypeScript types, not runtime behavior
  3. Mock-only tests: Tests that create mock objects and assert on hardcoded values
  4. No source imports: Tests that don't import anything from the actual codebase
  5. Admission comments: Tests with comments like "In a real test, this would..."
  6. Built-in testing: Tests that only verify JavaScript's typeof or other built-ins
  7. Fake integration tests: "Integration" tests that never make HTTP requests

Example Output

🔍 Found 3 suspicious test file(s):

🔴 src/__tests__/events.fixed.test.ts
   Confidence: HIGH | Lines: 407
   Reasons:
     - Defines 3 inline implementation(s) instead of importing real ones
     - Creates 12 mock objects and asserts on hardcoded values
     - No imports from actual implementation (only test utilities)

🟡 api/__tests__/types.test.ts
   Confidence: MEDIUM | Lines: 121
   Reasons:
     - Appears to test TypeScript types, not runtime behavior
     - More than 50% of assertions test JavaScript built-ins (typeof, etc)

💡 Recommendation:
   Review these files manually. High confidence files are likely useless.
   Delete files that don't import and test actual implementations.

Philosophy

Not all "bad" tests are useless, but tests that don't exercise real code paths provide zero value and create false confidence.

This tool flags obvious cases where tests:

  • Don't import the code they claim to test
  • Only test TypeScript's type system (which already runs at compile time)
  • Create inline mocks that duplicate production logic

License

MIT