{"id":19020344,"url":"https://github.com/ambar/rollup-jest","last_synced_at":"2025-04-23T05:45:20.595Z","repository":{"id":38414832,"uuid":"166635693","full_name":"ambar/rollup-jest","owner":"ambar","description":"Rollup preprocessor for Jest","archived":false,"fork":false,"pushed_at":"2023-01-08T17:24:24.000Z","size":405,"stargazers_count":18,"open_issues_count":2,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T05:45:13.666Z","etag":null,"topics":["jest","rollup","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ambar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-20T07:41:27.000Z","updated_at":"2022-12-09T16:21:51.000Z","dependencies_parsed_at":"2023-02-08T07:01:10.117Z","dependency_job_id":null,"html_url":"https://github.com/ambar/rollup-jest","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambar%2Frollup-jest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambar%2Frollup-jest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambar%2Frollup-jest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ambar%2Frollup-jest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ambar","download_url":"https://codeload.github.com/ambar/rollup-jest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250379784,"owners_count":21420841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jest","rollup","testing"],"created_at":"2024-11-08T20:16:53.259Z","updated_at":"2025-04-23T05:45:20.577Z","avatar_url":"https://github.com/ambar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rollup-jest\n\nRollup preprocessor for Jest.\n\n[![Coverage Status](https://coveralls.io/repos/github/ambar/rollup-jest/badge.svg?branch=master)](https://coveralls.io/github/ambar/rollup-jest?branch=master)\n[![npm version](https://badgen.net/npm/v/rollup-jest)](https://www.npmjs.com/package/rollup-jest)\n\n## Install\n\n```bash\nnpm install rollup-jest rollup --save-dev\n```\n\n## Usage\n\nAdd preset to Jest config:\n\n```json\n{\n  \"jest\": {\n    \"preset\": \"rollup-jest\"\n  }\n}\n\n// alternatively, specifying the files to transform:\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.m?js$\": \"rollup-jest\"\n    },\n  }\n}\n\n// or with options:\n// the preset enables sourcemaps by default\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.m?js$\": [\"rollup-jest\", {\"output\": {\"sourcemap\": true}}]\n    },\n  }\n}\n```\n\nWrite your tests with ES modules:\n\n```js\nimport path from 'path'\n\ntest('parses extname', () =\u003e {\n  expect(path.extname('foo.md')).toBe('.md')\n})\n```\n\nHappy testing!\n\n## Configuration\n\n### Use `configFile` field\n\nNOTE: To use ESM format `configFile` in Rollup v3, you should add `--experimental-vm-module` flag to run jest，eg. `NODE_OPTIONS=--experimental-vm-modules npm run test`\n\n```json\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.js$\": [\"rollup-jest\", {\"configFile\": \"./rollup.config.js\"}]\n    }\n  }\n}\n```\n\n`rollup.config.js`:\n\n```js\nimport inject from '@rollup/plugin-inject'\n\nlet config = {}\nif (process.env.NODE_ENV === 'test') {\n  config = {\n    plugins: [inject({React: 'react'})],\n  }\n}\n\nexport default config\n```\n\n### Use inline config\n\n```json\n{\n  \"jest\": {\n    \"transform\": {\n      \"\\\\.js$\": [\n        \"rollup-jest\",\n        {\"plugins\": [[\"@rollup/plugin-inject\", {\"React\": \"react\"}]]}\n      ]\n    }\n  }\n}\n```\n\n### All options\n\n- `useCache: boolean`: Default `true`. Enable caching of entry module. This can mess with plugins (e.g. typescript).\n- `resolveImports: 'relative' | boolean`: Default `false`. Resolve (bundle) imports, either all (incl. packages) or only relative files.\n- `args: any`: If your config file exports a function, you can use this field to pass arguments that aren't supported in rollup's `inputOptions`.\n- `plugins: Plugin[]`: Gets merged with plugins from config file. Special syntax `[name, options]` allows you to specify the plugin in json without `require`.\n\n## Related\n\n- [es-jest](https://github.com/ambar/es-jest)\n- [babel-jest](https://github.com/facebook/jest/tree/master/packages/babel-jest)\n- [ts-jest](https://github.com/kulshekhar/ts-jest)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fambar%2Frollup-jest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fambar%2Frollup-jest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fambar%2Frollup-jest/lists"}