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

@zof-ai/flaky-test-detector

v0.1.1

Published

Offline observed test instability analysis from repeated JUnit observations

Readme

@zof-ai/flaky-test-detector

Analyze repeated test outcomes locally to identify observed instability. The tool imports JUnit XML or explicit JSON observations, tracks pass/fail transitions, ranks tests for review, and distinguishes insufficient samples, missing observations, skipped tests and execution errors. It never executes or quarantines tests.

Observed inconsistency does not prove that a test is flaky. Source changes, changing inputs, infrastructure, or environment differences may explain it. No confidence score is presented as scientific certainty.

Install from npm

Use Node.js 22 or 24 and npm. File-based operations require Linux or macOS with Python 3.10 or newer; Windows file operations fail closed. In a new project directory, install the version used by this guide:

npm install --ignore-scripts --save-exact @zof-ai/[email protected]
npx --no-install zof-flaky-test-detector --help

The package includes compiled JavaScript, TypeScript declarations and its runtime dependencies. No source build, Zof account or repository upload is required. --ignore-scripts disables installation lifecycle scripts; --no-install keeps the example commands from downloading another package.

Confirm the public ESM entry point; this prints function:

node --input-type=module -e "import('@zof-ai/flaky-test-detector').then(api => console.log(typeof api.detectFlakiness))"

Run a packaged example from the same directory:

npx --no-install zof-flaky-test-detector --root node_modules/@zof-ai/flaky-test-detector/examples --observations stable-observations.json --min-samples 3 --json

The three completed observations report a stable test, without quarantining or executing tests.

Package: @zof-ai/flaky-test-detector. The source-checkout instructions and three additional workflows follow.

Install from GitHub source

Requires Node.js 22 or 24, npm, and Git. Filesystem operations require Linux or macOS with Python 3.10 or newer; Windows file operations fail closed. Clone this repository and explicitly prepare its reviewed release dependencies:

git clone --branch v0.1.1 --depth 1 https://github.com/Zof-AI/zof-flaky-test-detector.git
cd zof-flaky-test-detector
node scripts/bootstrap.mjs --allow-network
npm ci --ignore-scripts --prefer-offline
npm run build
npm test

The bootstrap downloads only the exact versioned dependency assets from GitHub Releases, as listed in scripts/release-dependencies.json, verifies SHA256 and byte size, and adds them to the npm cache. It does not extract archives, run package scripts, collect application data, or send credentials. Downloads require the explicit flag and follow only HTTPS GitHub asset redirects. Installation then fetches ordinary third-party dependencies from npm. Use a writable npm cache; set npm_config_cache consistently for both commands if needed. An unavailable asset, changed hash, or oversized response stops installation.

Quick start

Requires Node.js 22 or 24. After the source installation above:

npm ci --ignore-scripts
npm run build
node dist/cli.js --root examples --observations stable-observations.json --json

The output identifies three observed passing results for stable. The package identifier is @zof-ai/flaky-test-detector; the executable name is zof-flaky-test-detector.

Three examples

# Three repeated JUnit runs: stable, failing, intermittent and insufficient-data cases.
# Exit 1 because observed instability was explicitly requested as a CI failure condition.
node dist/cli.js --root examples --junit junit/run-1.xml --junit junit/run-2.xml --junit junit/run-3.xml --json --fail-on-instability
# Three consistently observed passes; no claim about future stability.
node dist/cli.js --root examples --observations stable-observations.json --json
# A skipped run breaks transition adjacency; observed pass/fail sample count is two.
# Exit 3 because observations are incomplete.
node dist/cli.js --root examples --observations gapped-observations.json --min-samples 2 --json

JUnit arguments must be in chronological execution order; files are never sorted by filename. Duplicate paths are rejected. Each file represents one run. A path or user-provided run ID cannot establish that a run is authentic or independently executed.

API and JSON contract

import { detectFlakiness, analyzeJUnit, formatReport } from '@zof-ai/flaky-test-detector';
const report = await analyzeJUnit({
  root: '/absolute/path/to/synthetic-results',
  files: ['run-1.xml', 'run-2.xml', 'run-3.xml'],
  minSamples: 3
});
console.log(formatReport(report));

detectFlakiness(runs, { minSamples? }) accepts an array of runs:

[{"id":"run-1","status":"completed","tests":[{"name":"suite::test","status":"passed"}]}]

Run statuses are completed, partial, missing and error. Test outcomes are passed, failed, skipped and error. Run IDs and per-run test names must be unique, including after redaction. analyzeObservationFile(root, relativePath, options?) loads this format safely. Missing runs cannot contain test observations. Unknown fields and invalid statuses fail explicitly.

JUnit import uses the shared @zof-ai/ci-evidence normalizer. Test identity is classname::name where a class is supplied, otherwise suite-name::name for the nearest named suite, otherwise the test name. Ambiguous or redacted identity collisions fail rather than conflating tests. Malformed or unavailable artifacts become explicit run errors while usable observations are preserved.

Reports use test-instability/v1. Fields include runCount, minSamples, complete, ranked tests, runIssues, limitations, verificationResult: "not-run" and quarantinedTests: []. Per-test metrics include pass/fail/skipped/error/missing counts, evaluated samples, adjacent comparable pairs, transitions, observed failure rate and observed transition rate.

Classification and calculations

The minimum pass/fail sample count defaults to 3 and may be set from 2 through 256.

  • Fewer eligible samples: insufficient-data.
  • Both passing and failing outcomes with enough samples: observed-instability.
  • Otherwise, recorded execution errors: execution-errors.
  • All eligible outcomes fail: consistent-fail.
  • All eligible outcomes pass: consistent-pass.

An eligible sample is a reported pass or fail. Skipped, missing and error observations stay separate. observedFailureRate = failed / (passed + failed), or null without eligible observations. A transition is a change between passing and failing in adjacent input runs. Skips, errors and missing tests break adjacency. observedTransitionRate = transitions / comparableAdjacentPairs, or null when no adjacent pair is comparable.

Ranking prioritizes observed instability, execution errors, consistent failure, insufficient data, then consistent passing. Within each category it sorts by descending transition count, descending failure count and test name. This is a review order, not a probability estimate. Error counts never silently become failed assertions.

complete means all supplied runs contain observations, each discovered test meets the threshold in every supplied run, and there are no missing/skipped/error outcomes. It does not prove test stability, outcome authenticity, or comprehensive test execution. A partial run can preserve explicitly reported case outcomes while keeping the whole report incomplete.

CI and security

Exit codes are 0 analysis completed with sufficient observations, 1 observed instability when --fail-on-instability is set, 2 invalid input/identity or operational failure, and 3 incomplete observations. An explicitly requested instability failure takes precedence over incompleteness; both remain visible in JSON. Without the flag, inspect classifications directly. No exit status proves verification passed.

Input limits: up to 64 JUnit files, 4 MiB per file, 32 MiB total XML, 256 JSON runs, 10,000 cases per run, and 100,000 observations total. JSON files are limited to 4 MiB. Analysis and report serialization also obey the shared evidence bounds. XML document types and entities are prohibited; external resources are never fetched. No archive extraction occurs. Paths must stay inside an explicit root; symlinks, traversal and URL inputs cannot be read.

The importer ignores application logs, XML properties, failure bodies, environment variables and source content. Recognizable credentials and URL metadata are redacted. Avoid secrets in test names because no redactor can recognize every arbitrary secret. Reads are anchored to directory descriptors and reject symlink replacement; file contents can still change during capture. No network, commands or repository tests run during analysis. No automatic quarantine or uploaded evidence is performed.

Validation and release

npm test
npm pack --ignore-scripts

Tests cover deterministic JUnit outcomes, qualified identity handling, exact transition denominators, gaps, insufficient samples, duplicate observations, XXE, malformed/oversized XML, missing files, symlinks, redaction, documented CLI commands and a clean tarball installation with explicit candidate dependencies. CI targets Linux/macOS on Node 22/24; only completed jobs establish platform verification. See security policy and release procedure. Versioned GitHub releases record installation and validation details.