Registry / testing / jest-pnp-resolver

jest-pnp-resolver

JSON →
library1.2.3jsnpmunverified

A plug'n'play (PnP) resolver for Jest that enables resolution of dependencies in Yarn PnP environments. Current stable version is 1.2.3, with infrequent releases. Key differentiators: it is the official resolver for Yarn PnP with Jest, and as of Jest 24.4.0+, it is integrated by default, but manual setup may still be needed for custom configurations or older versions. Alternatives include using the default Jest resolver with node_modules or other custom resolvers for different package managers.

npm install jest-pnp-resolver
INSTALL
IMPORT
SIG · JEST-PNP-RESOLVER
J
jest-pnp-resolver
testingjavascriptv1.2.3
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-pnp-resolver
import 'jest-pnp-resolver'
import { jest-pnp-resolver } from 'jest-pnp-resolver'
The module is a CommonJS module and uses default export. It is not a named export.
require.resolve
resolver: require.resolve('jest-pnp-resolver')
resolver: 'jest-pnp-resolver'
Use require.resolve to get the absolute path to the resolver module.
module.exports
module.exports = { resolver: require.resolve('jest-pnp-resolver') }
module.exports = { resolver: 'jest-pnp-resolver' }
The resolver configuration must be the path, not the package name.

Configures Jest to use the PnP resolver for resolving modules in a Yarn PnP project.

// jest.config.js module.exports = { resolver: require.resolve('jest-pnp-resolver') };
Debug
Known issues
deprecatedAs of Jest 24.4.0+, the default resolver already supports PnP, making jest-pnp-resolver unnecessary for most users.
fix
Remove resolver configuration from jest.config.js to use the built-in PnP support.
affects: >=24.4.0
breakingThis resolver only works with Yarn PnP (plug'n'play) installations. It will fail if used with a node_modules-based setup.
fix
Ensure your project uses Yarn PnP (i.e., has .pnp.js or .pnp.cjs file).
affects: all
gotchaUsing require.resolve('jest-pnp-resolver') in jest.config.js may resolve to the wrong path if the package is not installed.
fix
Install jest-pnp-resolver as a devDependency: yarn add -D jest-pnp-resolver
affects: all
gotchaThe resolver does not support custom module directories or moduleNameMapper patterns that rely on node_modules.
fix
Use transform or other Jest configuration to adjust module resolution.
affects: all
Errors
Common errors & fixes
Cannot find module 'jest-pnp-resolver'
Package not installed or not in node_modules.
fix
Run yarn add -D jest-pnp-resolver
Could not locate module … mapped as …
moduleNameMapper is not compatible with PnP resolution when mapping to node_modules paths.
fix
Update moduleNameMapper to map to actual file paths within PnP virtual file system.
Jest encountered an unexpected token …
Usually due to missing Babel transpilation; PnP resolver alone does not handle syntax transforms.
fix
Add appropriate transform configuration in jest.config.js (e.g., babel-jest).
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies
jest-resolverequiredpeer dependency required for resolver compatibility
Agent activity
9 hits · last 30 days
node
8
Resources
jest-pnp-resolver — npm install jest-pnp-resolver · libregistry