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

testwitness

v0.1.3

Published

Did this PR weaken its tests, and did they actually run? Flags deleted, skipped and loosened tests and checks the test results (JUnit XML, TAP, Jest, Vitest, pytest-json-report and Playwright JSON).

Readme

testwitness

testwitness reads a pull request's diff and test results and tells the reviewer when tests were deleted, skipped or loosened, or did not run.

A terminal running git diff on a branch that loosens one assertion, skips one test and deletes another, then testwitness check reporting review with one medium finding (R003, test skipped), and the loosened assertion and the deleted test counted in the summary and kept among the low findings, since those rules report at low in v0.1

npx testwitness check --base origin/main
npx testwitness check --pr https://github.com/<owner>/<repo>/pull/<n>   # trial on a public PR, no clone needed

Needs Node 20 or newer and a git checkout with the base branch fetched. Supported on Linux and macOS; Windows is experimental in v0.1 and tracked in an issue. For pull requests, use the GitHub Action.

v0.1 reports three rules at medium or high: R003 (test newly skipped), R004 (test turned into an expected failure) and R005 (focused test added). Every other rule runs and reports at low until it passes an untuned replay. A002 (assertion loosened) was the fourth until 0.1.2: on real agent pull requests 1 of its 18 findings was real, so it is capped at low until it passes a fresh unseen set. Two numbers, both on pull requests no rule was tuned on (how we measure):

  • Noise: on 300 ordinary merged pull requests from 20 repositories testwitness was never tuned on, 0.1.1 reported 3 findings at medium or high, 1.0 per 100 pull requests. All 3 were wrong: two loosened assertions that were exact checks of a new value (A002, capped at low since 0.1.2), and a skip added to a test that already ran nothing. So false findings are rare on ordinary work, but not zero. Measured 14 November 2026, judged by two independent judges with a written rubric where a doubtful finding counts as false.
  • Real agent pull requests: a study of how often coding agents weaken tests, on 3,142 public pull requests from 60 repositories. In merged agent work it is rare, 0.16 to 0.32 per 100 pull requests depending on how judge disagreements are counted; in agent pull requests closed without merge it is 0.60 to 1.04 per 100. When testwitness reports at medium or high it has been right (R003, 3 of 3 pull requests), but it misses most weakenings, chiefly loosened assertions, which 0.1.2 reports at low. Limits, method fixed in advance and intervals: docs/agent-pr-evaluation.md.

What it checks

testwitness is a GitHub Action and a CLI that reads a pull request's diff, the test code (tree-sitter) and the test results from the run (JUnit XML, TAP, or the JSON output of Jest, Vitest, pytest-json-report or Playwright), and tells the reviewer whether the tests still mean anything: deleted, skipped, loosened, tautological, assertion free, swallowed in a catch all, excluded in config, suppressed in CI, or claimed but never run. Java (JUnit 4 and 5, TestNG, AssertJ, Mockito), TypeScript and JavaScript (Jest, Vitest, Mocha, Playwright Test), Python (pytest, unittest). Works on PRs from Claude Code, Codex, Copilot, Cursor, Devin and people. No model, no secrets, no network (the --pr trial alone fetches the pull request with git).

Why it exists: a June 2026 study of 86,156 agent authored test patches found 80.2% had weak or no explicit oracle (arXiv 2606.18168), and inaccurate self reporting is the failure mode that grows over time in real sessions (arXiv 2605.29442). CI is green either way. testwitness puts the answer on the PR.

GitHub Action

# .github/workflows/testwitness.yml
name: testwitness
on:
  pull_request:
permissions:
  contents: read
  pull-requests: write # to post the comment; without it findings still show as annotations
jobs:
  testwitness:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0
      - uses: testwitness/testwitness@v0
        with:
          results: "**/junit*.xml,**/TEST-*.xml,**/test-results/**/*.xml"

That is the whole install when your test job already writes JUnit XML into the workspace (Surefire and Gradle do by default; pytest needs --junitxml, Jest needs jest-junit, Vitest --reporter=junit, Playwright the junit reporter). JUnit XML is the first recommendation. When a runner only gives you TAP (node --test --test-reporter=tap) or a JSON report (jest --json, vitest --reporter=json, pytest --json-report, Playwright --reporter=json), point results at that file instead; the format is told from the content (evidence). results used to be called junit, and junit still works. Without any results the diff rules still run and the evidence section reads unreadable.

The CLI ships as one npm package with no runtime dependencies and runs the same engine locally or in any CI:

npx testwitness check --base origin/main --head HEAD --results "**/junit*.xml"
# or install it once
npm i -g testwitness
testwitness check --base origin/main --results "**/junit*.xml"

See docs/cli.md for every option.

Inside the agent's loop

The same engine can run before the pull request exists, as a hook in Claude Code, Cursor or Codex, or as a git pre-push hook. When the agent tries to commit, push or end its turn with weakened tests in the working tree, the hook blocks and hands back the rule, the file, the line and the base text to restore. It blocks the same finding at most twice per session, and a crash or a timeout lets the action through.

The block message ends with a run ledger: what the session can actually claim about its tests, counted from its own commands, exit codes and edits (the last full run and its result, runs narrowed to one file, exit statuses hidden by | tail, files changed after the last run). testwitness ledger --transcript <file> prints the same for any Claude Code or Codex session. See the run ledger.

npm i -g testwitness
testwitness init --agent claude    # or cursor, codex, git

In Claude Code you can install it as a plugin instead, with the hook and the read only MCP server bundled (the package must be installed as above): /plugin marketplace add testwitness/testwitness, then /plugin install testwitness@testwitness.

By default it blocks on the same three rules, at medium and above, and on changes to the gate itself. Every other rule, deleted tests included, stays quiet until it passes an untuned replay; a maintainer can opt a rule in and widen the list. What it blocks, the numbers and the limits: docs/agent-guard.md.

What it reports

Three states, never a verdict about honesty:

  • pass: no finding at or above the configured threshold (fail_on, medium by default, so a finding of any of the three proven rules puts the PR in review).
  • review: this PR changed what its tests prove. A reviewer should look.
  • unreadable: the diff rules ran, but no test results were available to confirm what ran.

One PR comment, updated in place, with a four number summary (tests deleted, tests skipped, assertions removed or loosened, changed tests that did not run), a table of findings with file and line, the evidence section, and provenance (agent trailers, shown and never used to change the rules). Findings are also emitted as annotations on the Files tab, which works on fork PRs with a read only token, plus testwitness.json and testwitness.md in the workspace.

Rules in v0.1

v0.1 reports 3 rules at medium or high, the proven ones. Their numbers on the public PR corpus (docs/precision.md):

| Rule | Finding | Severity | True positives (corpus) | False positives (medium or high) | Held out precision (medium or high) | |---|---|---|---|---|---| | R003 | Test newly skipped or disabled | medium | 64 | 0 | 1.00 | | R004 | Test converted to expected failure | high | 28 | 0 | 1.00 | | R005 | Focused test added | high | 15 | 0 | 1.00 |

Every other rule still runs, but its findings are capped at low (informational, collapsed in the comment) until it passes an untuned replay on pull requests from repositories it was never tuned on (how we measure). W006, a change to the gate itself, is the one exception and keeps its severity. A repository can opt a rule back in by naming its severity in .testwitness.yml, for example rules: { R001: medium }. The severity in brackets is what the rule says before the cap; the corpus counts are judged at that severity:

  • R001 Test function deleted (says medium): 32 true positives, 19 false positives on the corpus
  • R002 Test file deleted (says high): 12 true positives, 3 false positives on the corpus
  • R006 Test body emptied or commented out (says high): no true positive on the corpus yet
  • R010 Test added then skipped (says low): 13 true positives, 0 false positives on the corpus
  • A001 Assertion removed (says low): 14 true positives, 0 false positives on the corpus
  • A002 Assertion loosened (says medium): 27 true positives, 1 false positive on the corpus
  • A009 Tautological assertion (says low): 3 true positives, 0 false positives on the corpus
  • O001 New test without an assertion (says low): 5 true positives, 0 false positives on the corpus
  • O002 New test with a smoke oracle only (says low): 6 true positives, 0 false positives on the corpus
  • O006 New test file with no tests collected (says medium): no true positive on the corpus yet
  • E001 Catch all added in a test (says high): 3 true positives, 0 false positives on the corpus
  • W002 continue-on-error added to a test step or job (says high): 9 true positives, 2 false positives on the corpus
  • W003 Failure suppressed in the run command (says high): 1 true positive, 0 false positives on the corpus
  • S004 Snapshot update enabled in the test command (says high): no true positive on the corpus yet
  • C001 Test selection narrowed in config (says high): 7 true positives, 0 false positives on the corpus
  • C002 Coverage threshold lowered or removed (says medium): 10 true positives, 1 false positive on the corpus
  • C003 Passing with no tests enabled (says high): 1 true positive, 2 false positives on the corpus
  • V003 Changed test did not run (says high): no true positive on the corpus yet
  • V004 Claim in PR text not supported by results (says medium): 9 true positives, 0 false positives on the corpus
  • V005 No test results found (says low): no true positive on the corpus yet
  • V006 Failures in results while the PR claims passing (says high): no true positive on the corpus yet

The full catalogue with false positive controls is in docs/rules.md.

Precision

Measured on a corpus of real public pull requests chosen because a naive detector would flag them (honest refactors) plus a few real weakenings. See docs/precision.md for the per rule table, regenerated with pnpm corpus:report; it judges every rule at the severity the rule gives before the cap, so the rules that are not proven yet stay measured. How the corpus is built and labelled, the held out split and the known limits: docs/how-we-measure-precision.md. Low findings (moved, parameterised, refactored, conditional) are informational and collapsed in the comment.

Configuration

Optional .testwitness.yml at the repository root, read from the base ref so a PR cannot relax its own check:

mode: report          # report | require-ack | strict
fail_on: medium
rules:
  R003: high
  R001: medium        # naming a severity opts a rule that is not proven yet back in
  O006: off
assertions:
  extra: ["assert_ledger_balanced", "com.acme.test.Check#*"]
acknowledge:
  - fingerprint: "R003:src/test/java/com/acme/PaymentsIT.java:PaymentsIT#pollsSettlement"
    reason: "needs a live sandbox, tracked in PAY-412"
    by: sajjad
    date: 2026-11-20

Security and privacy

Runs on pull_request with contents: read. No secrets, no network calls from the engine, no execution of your code: grammars are bundled, configs are parsed as text. The Action talks only to the GitHub API, for the optional comment and the acknowledgements. Nothing leaves the runner; the JSON report stays in your workspace. See docs/design.md.

Development

pnpm install
pnpm check          # typecheck, lint, unit tests
pnpm fixtures       # golden fixture cases per language and framework
pnpm corpus:report  # precision on the public PR corpus

Layout: packages/core (engine and rules), packages/lang-* (tree-sitter front ends and .scm queries), packages/junit (test results readers: streaming JUnit XML and TAP, JSON reporters), packages/cli, packages/action, fixtures/ (real projects with real JUnit XML, TAP and JSON results and golden cases), corpus/ (public PR patches with hand labels).

Licence

Apache 2.0.