Registry / testing / jest-runner-prettier

jest-runner-prettier

JSON →
library1.0.0jsnpmunverified

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.

npm install jest-runner-prettier
INSTALL
IMPORT
SIG · JEST-RUNNER-PRETTI
J
jest-runner-prettier
testingjavascriptv1.0.0
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-runner-prettier
import 'jest-runner-prettier'
const runner = require('jest-runner-prettier')
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.
preset
module.exports = { preset: 'jest-runner-prettier' }
module.exports = { preset: 'jest-runner-prettier/preset' }
The preset is accessed via the package name itself, not a subpath. The README shows 'preset: "jest-runner-prettier"'.
runner
module.exports = { runner: 'prettier' }
module.exports = { runner: 'jest-runner-prettier' }
The runner name in Jest config is 'prettier' (derived from the package), not the full package name.

Installs dependencies, configures Jest with the preset, and runs the formatter as a test.

npm install --save-dev jest prettier jest-runner-prettier # jest.config.js module.exports = { preset: 'jest-runner-prettier', }; # or manually: // module.exports = { // runner: 'prettier', // moduleFileExtensions: ['js', 'ts', 'json', 'md'], // testMatch: ['**/*.js', '**/*.ts', '**/*.json', '**/*.md'], // }; # Run Jest npx jest
Debug
Known issues
breakingv1.0.0 requires Jest >= 27 and Node >= 12. Also targets ES modules, breaking CJS usage.
fix
Upgrade Jest to at least 27, Node to >=12, and ensure your project supports ESM or use a bundler.
affects: >=1.0.0
deprecatedVersion 0.3.x uses jest-diff v24, which may cause compatibility issues with Jest 27.
fix
Upgrade to v1.0.0 or later.
affects: >=0.3.0 <1.0.0
gotchaThe package name in Jest runner config is 'prettier' not 'jest-runner-prettier'.
fix
Use runner: 'prettier' in Jest config.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'jest-runner-prettier'
The package is not installed or not in node_modules.
fix
Run npm install --save-dev jest prettier jest-runner-prettier
Cannot use import statement outside a module
The package is ESM-only from v1.0.0, but project is configured as CommonJS.
fix
Set type: 'module' in package.json or use a CommonJS-compatible version (<1.0.0).
Configuration error: Unknown runner "prettier"
Jest cannot find the runner because the package is not installed or configured incorrectly.
fix
Ensure jest-runner-prettier is installed and listed in devDependencies.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
jestrequiredPeer dependency - Jest is required to run this plugin
prettierrequiredPeer dependency - Prettier is the formatter
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
jest-runner-prettier — npm install jest-runner-prettier · libregistry