Registry / testing / jest-watch-repeat

jest-watch-repeat

JSON →
library3.0.1jsnpmunverified

Jest-watch-repeat is a Jest watch plugin that enhances the developer experience by allowing users to repeat their test suites multiple times directly from Jest's interactive watch mode. This functionality is particularly useful for debugging flaky tests, stress testing components, or simply running a set of tests in a loop without manual intervention. The current stable version is 3.0.1. The package releases are often tied to major Jest version updates, as seen with version 3.0.0 updating for Jest 29 compatibility. Its key differentiator is its seamless integration into Jest's native watch mode, providing a convenient 'r' key shortcut and prompt for configuring the repetition count, including the ability to retry only failed tests.

npm install jest-watch-repeat
INSTALL
IMPORT
SIG · JEST-WATCH-REPEAT
J
jest-watch-repeat
testingjavascriptv3.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jest-watch-repeat (plugin name)
"watchPlugins": [ "jest-watch-repeat" ]
import { RepeatPlugin } from 'jest-watch-repeat';
Jest watch plugins are integrated by their package name string within the `watchPlugins` array in `jest.config.js`. Direct programmatic import of the plugin class is generally not necessary for typical usage.
jest-watch-repeat (with options)
"watchPlugins": [ ["jest-watch-repeat", { "key": "r", "always-repeat": true }] ]
"watchPlugins": { "jest-watch-repeat": { "key": "r" } }
To pass options, the plugin name must be wrapped in an array with the options object as the second element in Jest's `watchPlugins` configuration.
RepeatPlugin (class export)
const RepeatPlugin = require('jest-watch-repeat').default;
import RepeatPlugin from 'jest-watch-repeat';
While not typical for end-users, the plugin's main class is the default export. Version 3.0.1 explicitly downgraded internal dependencies (`ansi-escapes`, `chalk`) to pre-ESM versions, indicating a preference for CommonJS compatibility or robust interop, though direct ESM imports may vary based on your environment.

Configures `jest-watch-repeat` as a Jest watch plugin within `jest.config.js`, enabling test repetition via the 'r' key and demonstrating options for customization.

{ "jest": { "watchPlugins": [ "jest-watch-repeat", // Example with custom key and prompt: ["jest-watch-repeat", { "key": "r", "prompt": "repeat test runs." }], // Example with 'always-repeat' option: ["jest-watch-repeat", { 'always-repeat': true }] ] } }
Debug
Known issues
breakingVersion 3.0.0 updated dependencies, including Jest to v29, and introduced 'prompt changes' along with the ability to repeatedly run failed tests. This alters user interaction with the plugin's watch mode prompts.
fix
Review the new watch mode prompts and interactions. The plugin now supports retrying failed tests, which changes the workflow when prompted for repetitions. Ensure your Jest version is compatible (>=29).
affects: >=3.0.0
breakingVersion 3.0.0 introduced a peer dependency on `jest@>=29`. Older versions of `jest-watch-repeat` (e.g., v1.x, v2.x) require older Jest versions (e.g., `jest@23+`).
fix
Ensure your project's Jest version meets the `jest-watch-repeat` peer dependency requirements. For `jest-watch-repeat@3.x`, use `jest@29` or newer. For older versions of the plugin, consult their specific Jest compatibility matrix.
affects: >=3.0.0
gotchaVersion 3.0.1 explicitly downgraded `ansi-escapes` and `chalk` to 'pre-ESM world' versions to prevent compatibility issues. If other dependencies in your project pull in newer, ESM-only versions of these libraries, it might lead to unexpected behavior or dependency conflicts.
fix
Ensure `jest-watch-repeat` is at version `3.0.1` or higher. If encountering ESM-related dependency issues, you may need to explicitly define dependency resolutions in your `package.json` to ensure compatible versions of `ansi-escapes` or `chalk` are used across your project.
affects: 3.0.0
Errors
Common errors & fixes
Error: Watch plugin 'jest-watch-repeat' not found.
The `jest-watch-repeat` package is either not installed or not correctly added to the `watchPlugins` array in your Jest configuration.
fix
First, install the package: `npm install --save-dev jest-watch-repeat` or `yarn add -D jest-watch-repeat`. Then, ensure it's listed in your `jest.config.js` or `package.json`'s `jest.watchPlugins` array, for example: `"watchPlugins": ["jest-watch-repeat"]`.
TypeError: Cannot read properties of undefined (reading 'length') (or similar Jest configuration parsing errors)
Incorrect or malformed options are being passed to the `jest-watch-repeat` plugin within your Jest configuration. Jest's `watchPlugins` array requires a specific format for plugins with options.
fix
Verify that if you're passing options, `jest-watch-repeat` and its options are wrapped in an array: `["jest-watch-repeat", { 'always-repeat': true }]`. Avoid using an object syntax directly for the plugin entry.
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
jestrequiredThis is a Jest watch plugin and requires Jest to function. Version 3.0.0 and above require Jest >=29.
Agent activity
6 hits · last 30 days
node
6
Resources
jest-watch-repeat — npm install jest-watch-repeat · libregistry