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

@mergifyio/vitest

v2026.12.5

Published

Vitest reporter for Mergify Test Engine

Readme

@mergifyio/vitest

Find the Vitest tests that pass and fail on the same code, and quarantine them so they stop failing your CI. Requires a Mergify account; free for open source. Why tests go flaky in Vitest, and how to fix them: mergify.com/learn/flaky-tests/vitest.

A Vitest reporter that integrates seamlessly with Mergify, uploading OpenTelemetry traces of test executions to Mergify Test Engine, along with optional quarantine, flaky-test detection and test retry.

More information at https://mergify.com

Installation

Install the package as a dev dependency alongside vitest (>= 3.0.0):

npm install --save-dev @mergifyio/vitest

It needs Node.js 22 or later. Its CI detection is a native binding, prebuilt for Linux x86_64 and arm64 (glibc 2.28 or newer, as Node.js 22 itself needs, and musl), macOS arm64, and Windows x64. The macOS x86_64 (Intel) binding is best effort: published, but not tested before a release.

Usage

Register MergifyReporter in your vitest.config.ts:

import { defineConfig } from 'vitest/config';
import MergifyReporter from '@mergifyio/vitest';

export default defineConfig({
  test: {
    reporters: ['default', new MergifyReporter()],
  },
});

On GitHub Actions, grant the job id-token: write and set no token: the reporter exchanges the job's ID token for a Mergify token, once a trust policy of your organization allows the job (OIDC). On any other CI, set MERGIFY_TOKEN to a Mergify application key with the ci scope. Without either, the reporter stays silent and tests run normally.

How tests are named

A test is named by its file, relative to Vitest's root, then its suites and its title: tests/strings.test.ts > strings > uppercases. Two tests with the same suites and title in two files are two tests to Mergify.

Earlier versions left the file out (strings > uppercases). Upgrading starts each test's history on Mergify over under its new name, while the quarantine and flaky detection still recognise a test listed under its former name: a test quarantined before the upgrade stays quarantined, and the tests your default branch already runs are not taken for new ones.

Where quarantine and flaky detection apply

These two act on the run itself. The reporter adds a setup file to every project of your config, so quarantine applies the same way in each of the shapes below, and flaky detection in all but the last (see further down):

  • a single Node config;
  • each project under test.projects (or test.workspace before Vitest 3.2);
  • browser mode;
  • custom pools such as @cloudflare/vitest-pool-workers.

A runner you configured yourself keeps running underneath. The reporter supports Vitest 3.0 through 5.0.

The @mergifyio/vitest/runner entry point is gone: the reporter no longer installs a runner. If your config sets runner: '@mergifyio/vitest/runner', remove that line; the reporter alone now applies everything it used to.

Earlier versions applied them only to a single Node config. Under projects, in browser mode, or with a custom pool they did nothing, and the reporter printed no warning. If you use one of those shapes, quarantined failures now stop failing your job, and new tests are rerun in Node projects.

Flaky detection reruns tests once the run is over, in a Vitest run of their own that loads your configuration file: each file holding a test to rerun runs again in full, and only those tests repeat. It plans one budget for the whole run, and sizes each test's reruns from how long its own run took. On a pull request, a new test that fails one of its reruns fails the run, so that a flaky test does not merge. Vitest's own summary still lists that test as passed: the flaky-detection block names it.

It needs a native binary and your configuration file. Neither a browser project's page nor Cloudflare's Workers pool can load the binary: they ask the reporter how many times to run each test, and hand it each run, a page through Vitest's browser commands and the Workers pool through a service binding the reporter adds to the pool. A run configured only through Vitest's API, with no configuration file, does not rerun new tests, and says so.

Quarantine runs in every shape. A browser project's page, and a test in the Workers pool, ask the reporter whether a failure is quarantined.

A test Test Engine skips does not run, in any project: the runner skips it before the file's hooks run, and Vitest reports it skipped, with the reason. Its suite's beforeAll and afterAll hooks still run, even when every test of the suite is skipped.

The end-of-run output names any project where none of this applied: that happens when a custom runner overrides onBeforeRunTask without calling super, or when a version of the Workers pool stops starting its runtime with the options the reporter added its binding to.

Test retry

On a push to your repository's default branch, and in a run your merge queue checks for a test your target branch already knows, a test that fails runs again in the worker, page or Workers runtime that ran it, as Vitest retries a test: after the retries your own retry option asks for, and as many times as your repository allows on Mergify, within one time budget the run's workers spend together. If a retry passes, so does the test, and the run stays green; Mergify still records that it failed. Other pull requests and branches retry nothing, and a new test in the merge queue, a test that is quarantined or one that Mergify classifies as broken is not retried. A test flaky detection reruns once the run is over is retried like any other first: those reruns come too late to change the run's result.

It needs Vitest 4.1 or later, which asks whether to retry a test each time a try fails, and the native binary. A browser project's page cannot load it: it asks the reporter, which answers for each page's file. Pools that cannot load native modules retry nothing, and neither do tests declared to fail (it.fails) or that repeat (repeats).

A job that sets MERGIFY_TEST_RETRY_ENABLE=false retries nothing, whatever the repository sets.

Bisection steps: failures first

When Mergify's merge queue splits a failed batch, each bisection step only needs to tell whether it is red. The reporter asks Mergify, once, before any worker starts, whether the current run is such a step and, if so, runs first the files holding the tests this job failed in the run the step was split from (Fail First). If one of those tests fails again, the step is red whatever the rest does, so the run stops once those files have all run, and the queue can split again without waiting for the suite. If none fails again, the rest of the suite runs as usual. No test is ever skipped, so a green step still comes from a full suite.

It is on by default. A job that must always run its suite in its usual order sets MERGIFY_FAIL_FIRST_ENABLE=false, and never queries the endpoint. Only a recognised no (false, no, off, 0) turns it off. MERGIFY_TEST_SELECTION_ENABLE, its former name, is no longer read. It is also enabled per organization on Mergify's side: until yours has it, every run is served the full suite, says nothing about it, and still sends its results, which show what Fail First would do there.

It only ever asks in a build of a merge-queue batch, the only builds a bisection step can be: on GitHub Actions, the event of the draft pull request the queue opened; on any other build, the queue's git note on the branch, one git ls-remote against origin that runs while the tests are being collected. Every other build asks nothing and sends nothing. Of a batch's builds, only those below a failed batch, and not retrying their own checks, ask: the others cannot be a bisection step, and send their results only when the batch holds two pull requests or more, so a bisection step may read them, or when they failed. A build where git cannot answer (no origin, credentials the test step does not hold) asks, as it would without this.

Sharded jobs (--shard) are supported: each shard reports its own collection, by the files it runs.

At the end of the run the reporter sends Mergify what it concluded (the counts and the failing tests), which is what the next bisection step of the job is answered from. Any error, timeout, or unrecognised answer runs the full suite in its usual order; and if the run fails outside any test (a failing hook, a file that does not import, an unhandled error), its results are not sent to Mergify, so the next step runs its full suite in its usual order.

When the queue splits a failed batch, the files holding the tests that failed run first, and the run stops once they all ran and one of those tests failed again. Vitest knows a file's tests only once it has imported the file, so the reporter then collects the files the stop left unrun, to count every test of the run. It does that in a process of its own, which loads your configuration file, runs your global setup again and imports those files without running their tests. A global setup that cannot run twice at once, such as one that binds a fixed port, leaves those tests out of the count, and the run says so.

Environment variables

| Variable | Description | Default | |---|---|---| | MERGIFY_TOKEN | Mergify application key with the ci scope, required outside GitHub Actions | on GitHub Actions, the job's ID token | | MERGIFY_API_URL | Mergify API endpoint | https://api.mergify.com | | MERGIFY_CI_ENABLE | Force-enable outside CI | false | | MERGIFY_CI_DEBUG | Print spans to console instead of uploading | false | | MERGIFY_FAIL_FIRST_ENABLE | Set to false to never run first what a merge-queue bisection step of this job failed before | true | | MERGIFY_TEST_RETRY_ENABLE | Set to false to have this job retry no failing test, whatever the repository sets | true | | MERGIFY_TRACEPARENT | W3C distributed trace context | — |

VITEST_MERGIFY_ENABLE, the name MERGIFY_CI_ENABLE replaces, is deprecated: it still works when MERGIFY_CI_ENABLE is not set, and the summary at the end of the run says which name to switch to.

For detailed documentation, see the official guide.

Development

Clone the repo and install dependencies:

pnpm install

Available scripts (from this package's directory or with pnpm --filter @mergifyio/vitest):

| Command | What it does | |---|---| | pnpm test | Run the test suite once (vitest run) | | pnpm run build | Bundle the package with tsdown |