jest-watch-select-projects
raw JSON → 2.0.0 verified Sat Apr 25 auth: no javascript
Jest watch plugin (v2.0.0) that allows selecting which Jest projects to run when using Jest's --watch mode with multiple projects. Part of the jest-community ecosystem. Requires Jest 23+ and Node >=8. Key differentiator: interactive project selection in watch mode with keyboard navigation (space to toggle, enter to confirm), using displayName or basename. Minimal API surface but critical for monorepo workflows.
Common errors
error No projects found ↓
cause Jest config does not have a 'projects' array, so the plugin cannot list projects.
fix
Add 'projects: ["<rootDir>/packages/*"]' or similar to your Jest config.
error Cannot find module 'jest-watch-select-projects' ↓
cause Plugin not installed or not in node_modules.
fix
Run 'npm install --save-dev jest-watch-select-projects' or 'yarn add --dev jest-watch-select-projects'.
Warnings
gotcha Plugin does not work without Jest's --watch flag. Running jest without --watch will ignore the plugin. ↓
fix Ensure you run 'jest --watch' or 'jest --watchAll'.
gotcha If projects do not have displayName in their Jest config, the plugin uses the basename of the project path. If multiple projects have the same basename (e.g., two folders named 'utils'), selection can be confusing. ↓
fix Set unique displayName in each project's Jest config.
breaking v2.0.0 dropped support for Node versions below 8, which may break CI pipelines using older Node. ↓
fix Upgrade Node to >=8.
gotcha Plugin requires Jest 23 or newer. Older Jest versions do not support watchPlugins. ↓
fix Upgrade Jest to >=23.
Install
npm install jest-watch-select-projects yarn add jest-watch-select-projects pnpm add jest-watch-select-projects Imports
- default wrong
import jestWatchSelectProjects from 'jest-watch-select-projects'correctmodule.exports = { watchPlugins: ['jest-watch-select-projects'] } - module.exports (config) wrong
module.exports = { watchPlugins: [require('jest-watch-select-projects')] }correctmodule.exports = { watchPlugins: ['jest-watch-select-projects'] } - with options wrong
watchPlugins: [ 'jest-watch-select-projects', { key: 'X' } ]correctwatchPlugins: [ ['jest-watch-select-projects', { key: 'X', prompt() { ... } } ] ]
Quickstart
// jest.config.js
module.exports = {
projects: ['<rootDir>/packages/*'],
watchPlugins: ['jest-watch-select-projects'],
};
// package.json scripts
// "test:watch": "jest --watch"
// Run: npm run test:watch
// Press SPACE to toggle project selection, ENTER to confirm.