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-resolverVerified import paths — ran on the pinned version, not inferred.
Configures Jest to use the PnP resolver for resolving modules in a Yarn PnP project.
Remove resolver configuration from jest.config.js to use the built-in PnP support.
Ensure your project uses Yarn PnP (i.e., has .pnp.js or .pnp.cjs file).
Install jest-pnp-resolver as a devDependency: yarn add -D jest-pnp-resolver
Use transform or other Jest configuration to adjust module resolution.
Run yarn add -D jest-pnp-resolver
Update moduleNameMapper to map to actual file paths within PnP virtual file system.
Add appropriate transform configuration in jest.config.js (e.g., babel-jest).