{"id":20153,"library":"jest-runner-prettier","title":"jest-runner-prettier","description":"A Jest runner that formats files using Prettier. Current stable version is 1.0.0, released February 2022. It integrates Prettier into Jest as a custom runner, allowing you to check formatting as part of your test suite. Requires Jest >= 27.0.0 and Prettier >= 1.8. Ships TypeScript definitions. Key differentiator: provides a built-in Jest preset for easy configuration, supports all file types Prettier handles, and produces diff output on formatting failures. Suitable for CI pipelines to enforce consistent code style.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/keplersj/jest-runner-prettier","tags":["javascript","typescript"],"install":[{"cmd":"npm install jest-runner-prettier","lang":"bash","label":"npm"},{"cmd":"yarn add jest-runner-prettier","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-runner-prettier","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency - Jest is required to run this plugin","package":"jest","optional":false},{"reason":"Peer dependency - Prettier is the formatter","package":"prettier","optional":false}],"imports":[{"note":"The package does not export a symbol; it's a Jest runner used via configuration. v1.0.0 is ESM-only, so require() fails on Node 12+ with ESM.","wrong":"const runner = require('jest-runner-prettier')","symbol":"jest-runner-prettier","correct":"import 'jest-runner-prettier'"},{"note":"The preset is accessed via the package name itself, not a subpath. The README shows 'preset: \"jest-runner-prettier\"'.","wrong":"module.exports = { preset: 'jest-runner-prettier/preset' }","symbol":"preset","correct":"module.exports = { preset: 'jest-runner-prettier' }"},{"note":"The runner name in Jest config is 'prettier' (derived from the package), not the full package name.","wrong":"module.exports = { runner: 'jest-runner-prettier' }","symbol":"runner","correct":"module.exports = { runner: 'prettier' }"}],"quickstart":{"code":"npm install --save-dev jest prettier jest-runner-prettier\n\n# jest.config.js\nmodule.exports = {\n  preset: 'jest-runner-prettier',\n};\n\n# or manually:\n// module.exports = {\n//   runner: 'prettier',\n//   moduleFileExtensions: ['js', 'ts', 'json', 'md'],\n//   testMatch: ['**/*.js', '**/*.ts', '**/*.json', '**/*.md'],\n// };\n\n# Run Jest\nnpx jest","lang":"javascript","description":"Installs dependencies, configures Jest with the preset, and runs the formatter as a test."},"warnings":[{"fix":"Upgrade Jest to at least 27, Node to >=12, and ensure your project supports ESM or use a bundler.","message":"v1.0.0 requires Jest >= 27 and Node >= 12. Also targets ES modules, breaking CJS usage.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Upgrade to v1.0.0 or later.","message":"Version 0.3.x uses jest-diff v24, which may cause compatibility issues with Jest 27.","severity":"deprecated","affected_versions":">=0.3.0 <1.0.0"},{"fix":"Use runner: 'prettier' in Jest config.","message":"The package name in Jest runner config is 'prettier' not 'jest-runner-prettier'.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run npm install --save-dev jest prettier jest-runner-prettier","cause":"The package is not installed or not in node_modules.","error":"Cannot find module 'jest-runner-prettier'"},{"fix":"Set type: 'module' in package.json or use a CommonJS-compatible version (<1.0.0).","cause":"The package is ESM-only from v1.0.0, but project is configured as CommonJS.","error":"Cannot use import statement outside a module"},{"fix":"Ensure jest-runner-prettier is installed and listed in devDependencies.","cause":"Jest cannot find the runner because the package is not installed or configured incorrectly.","error":"Configuration error: Unknown runner \"prettier\""}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}