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-repeatVerified import paths — ran on the pinned version, not inferred.
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.
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).
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.
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.
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"]`.
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.