Registry / testing / rollup-jest

rollup-jest

JSON →
library3.1.0jsnpmunverified

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-jest
INSTALL
IMPORT
SIG · ROLLUP-JEST
R
rollup-jest
testingjavascriptv3.1.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 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (preset)
// In jest.config.json: "preset": "rollup-jest"
Using require('rollup-jest') in jest config
Used as a Jest preset, not imported directly.
transform entry
// In jest.config.json: "transform": { "\\.m?js$": "rollup-jest" }
Trying to import rollup-jest as a module in test files
Configured in Jest's transform field, not imported in user code.
with options
// In jest.config.json: "transform": { "\\.js$": ["rollup-jest", {"configFile": "./rollup.config.js"}] }
Passing options as second argument to import statement
Options are passed as array in Jest transform config.

Install, configure preset, and write ES module test with default import.

npm install rollup-jest rollup --save-dev # jest.config.json { "jest": { "preset": "rollup-jest" } } # __tests__/example.test.js import path from 'path'; test('parses extname', () => { expect(path.extname('foo.md')).toBe('.md'); });
Debug
Known issues
breakingVersion 3 requires Rollup ^2.3.0 or ^3. Version 2 required Rollup ^1.0.0.
fix
Upgrade Rollup to ^2.3.0 or ^3 if using rollup-jest v3.
affects: >=3.0.0
deprecatedThe 'useCache' option may cause issues with plugins that have state (e.g. TypeScript).
fix
Set 'useCache: false' if experiencing stale results.
affects: >=1.0.0
gotchaTo use ESM configFile with Rollup v3, you must add --experimental-vm-modules to Node.js flags.
fix
Run Jest with NODE_OPTIONS=--experimental-vm-modules npm run test
affects: >=3.0.0 <4
gotchaDefault transform only matches .mjs and .js files. Other extensions like .ts or .jsx are not transformed unless explicitly added.
fix
Add a custom transform pattern for other extensions, e.g. "\\.ts$": "rollup-jest"
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'rollup-jest'
rollup-jest not installed or not in devDependencies
fix
npm install rollup-jest rollup --save-dev
Cannot use import statement outside a module
Jest not configured to transform the file with rollup-jest
fix
Add rollup-jest to Jest transform in jest.config.json
Jest encountered an unexpected token - SyntaxError: Unexpected token 'export'
File not transformed because transform pattern doesn't match
fix
Ensure the file extension matches the regex in Jest config (e.g., "\\.m?js$")
Upgrade
Version history
3.1.0latest on npm
Audit
Dependencies
rolluprequiredpeer dependency required for code transformation
Agent activity
6 hits · last 30 days
node
6
Resources
rollup-jest — npm install rollup-jest · libregistry