{"id":13385,"library":"jest-watch-repeat","title":"Jest Watch Repeat Plugin","description":"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.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/unional/jest-watch-repeat","tags":["javascript","jest","jest-watch-plugins","testing","tooling","typescript"],"install":[{"cmd":"npm install jest-watch-repeat","lang":"bash","label":"npm"},{"cmd":"yarn add jest-watch-repeat","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-watch-repeat","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This is a Jest watch plugin and requires Jest to function. Version 3.0.0 and above require Jest >=29.","package":"jest","optional":false}],"imports":[{"note":"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.","wrong":"import { RepeatPlugin } from 'jest-watch-repeat';","symbol":"jest-watch-repeat (plugin name)","correct":"    \"watchPlugins\": [\n      \"jest-watch-repeat\"\n    ]"},{"note":"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.","wrong":"    \"watchPlugins\": {\n      \"jest-watch-repeat\": { \"key\": \"r\" }\n    }","symbol":"jest-watch-repeat (with options)","correct":"    \"watchPlugins\": [\n      [\"jest-watch-repeat\", { \"key\": \"r\", \"always-repeat\": true }]\n    ]"},{"note":"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.","wrong":"import RepeatPlugin from 'jest-watch-repeat';","symbol":"RepeatPlugin (class export)","correct":"const RepeatPlugin = require('jest-watch-repeat').default;"}],"quickstart":{"code":"{\n  \"jest\": {\n    \"watchPlugins\": [\n      \"jest-watch-repeat\",\n      // Example with custom key and prompt:\n      [\"jest-watch-repeat\", { \"key\": \"r\", \"prompt\": \"repeat test runs.\" }],\n      // Example with 'always-repeat' option:\n      [\"jest-watch-repeat\", {\n        'always-repeat': true\n      }]\n    ]\n  }\n}","lang":"javascript","description":"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."},"warnings":[{"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).","message":"Version 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.","severity":"breaking","affected_versions":">=3.0.0"},{"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.","message":"Version 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+`).","severity":"breaking","affected_versions":">=3.0.0"},{"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.","message":"Version 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.","severity":"gotcha","affected_versions":"3.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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\"]`.","cause":"The `jest-watch-repeat` package is either not installed or not correctly added to the `watchPlugins` array in your Jest configuration.","error":"Error: Watch plugin 'jest-watch-repeat' not found."},{"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.","cause":"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.","error":"TypeError: Cannot read properties of undefined (reading 'length') (or similar Jest configuration parsing errors)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}