Rollup preprocessor for Jest that transforms files using Rollup. Current version 3.1.0, actively maintained. Allows using Rollup plugins and configuration in Jest tests, supporting ES modules. Key differentiator: integrates Rollup's bundling and plugin ecosystem into Jest's transform pipeline, enabling features like plugin injection, caching, and custom resolve behavior. Peer dependency on Rollup ^2.3.0 || ^3. Provides preset for zero-config setup. Suitable for projects already using Rollup who want to reuse rollup config in tests.
npm install rollup-jestVerified import paths — ran on the pinned version, not inferred.
Install, configure preset, and write ES module test with default import.
Upgrade Rollup to ^2.3.0 or ^3 if using rollup-jest v3.
Set 'useCache: false' if experiencing stale results.
Run Jest with NODE_OPTIONS=--experimental-vm-modules npm run test
Add a custom transform pattern for other extensions, e.g. "\\.ts$": "rollup-jest"
npm install rollup-jest rollup --save-dev
Add rollup-jest to Jest transform in jest.config.json
Ensure the file extension matches the regex in Jest config (e.g., "\\.m?js$")