{"id":13532110,"url":"https://github.com/skovhus/jest-codemods","last_synced_at":"2025-05-14T02:04:59.167Z","repository":{"id":37275960,"uuid":"68468109","full_name":"skovhus/jest-codemods","owner":"skovhus","description":"Codemods for migrating to Jest https://github.com/facebook/jest 👾","archived":false,"fork":false,"pushed_at":"2025-05-06T11:44:47.000Z","size":2423,"stargazers_count":884,"open_issues_count":38,"forks_count":82,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-06T12:54:05.162Z","etag":null,"topics":["ava","chai","codemod","codemods","jest","jest-codemods","jscodeshift","mocha","tape","testing"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/skovhus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-17T17:44:42.000Z","updated_at":"2025-04-22T13:38:48.000Z","dependencies_parsed_at":"2022-07-08T18:52:10.693Z","dependency_job_id":"71d596f3-753b-407d-95a1-6bc092bda798","html_url":"https://github.com/skovhus/jest-codemods","commit_stats":{"total_commits":710,"total_committers":60,"mean_commits":"11.833333333333334","dds":0.6605633802816901,"last_synced_commit":"95f107e1584e1180d2016ca479a148864e89b5c0"},"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fjest-codemods","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fjest-codemods/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fjest-codemods/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skovhus%2Fjest-codemods/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skovhus","download_url":"https://codeload.github.com/skovhus/jest-codemods/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254052692,"owners_count":22006716,"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":["ava","chai","codemod","codemods","jest","jest-codemods","jscodeshift","mocha","tape","testing"],"created_at":"2024-08-01T07:01:08.265Z","updated_at":"2025-05-14T02:04:59.138Z","avatar_url":"https://github.com/skovhus.png","language":"TypeScript","funding_links":[],"categories":["Packages","TypeScript","testing","By Environment","Testing","JavaScript"],"sub_categories":["Migration","JavaScript/TypeScript","Component"],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1\u003e jest-codemods 👾\u003c/h1\u003e\n\nCodemods that simplify migrating JavaScript and TypeScript test files from\n[AVA](https://github.com/avajs/ava),\n[Chai](https://github.com/chaijs/chai),\n[Expect.js (by Automattic)](https://github.com/Automattic/expect.js),\n[Expect@1.x (by mjackson)](https://github.com/mjackson/expect),\n[Jasmine](https://github.com/jasmine/jasmine),\n[Mocha](https://github.com/mochajs/mocha),\n[proxyquire](https://github.com/thlorenz/proxyquire),\n[Should.js](https://github.com/tj/should.js/),\n[Tape](https://github.com/substack/tape),\n[Sinon](https://github.com/sinonjs/),\nand\n[Node-Tap](https://github.com/tapjs/node-tap)\nto [Jest](https://facebook.github.io/jest/).\n\n[![version][version-badge]][package]\n[![downloads](https://img.shields.io/npm/dm/jest-codemods.svg?style=flat-square)](http://npm-stat.com/charts.html?package=jest-codemods\u0026from=2017-07-17)\n[![Code Coverage](https://img.shields.io/codecov/c/github/skovhus/jest-codemods.svg?style=flat-square)](https://codecov.io/github/skovhus/jest-codemods)\n[![MIT License](https://img.shields.io/npm/l/jest-codemods.svg?style=flat-square)](https://github.com/skovhus/jest-codemods/blob/master/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\n\u003c/div\u003e\n\n\u003cimg src=\"screenshot.gif\" width=\"300\" align=\"right\" style=\"margin-bottom: 1em; margin-left: 1em\"\u003e\n\nCodemods are small programs that help you automate changes to your codebase.\nThink of them as search and replace on steroids.\n\nWe made jest-codemods so you can try out Jest on your existing codebase.\nWe strive to make the migration as smooth as possible, but some manual intervention\nand tweaks to your tests are to be expected.\n\n\n## Usage (CLI)\n\n\nTo use the interactive CLI run\n\n\t$ npx jest-codemods\n\nIf you do not have `npx` installed, you can install the `jest-codemods` command globally by running `npm install -g jest-codemods`.\n\nFor more options\n```\n$ npx jest-codemods --help\n\n    Usage:      npx jest-codemods \u003cpath\u003e [options]\n\n    Examples:   npx jest-codemods src\n                npx jest-codemods src/**/*.test.js\n\n    Options:\n      -f, --force       Bypass Git safety checks and force codemods to run\n      -d, --dry         Dry run (no changes are made to files)\n```\n\nTo transform all test files in a directory run `jest-codemods .` in your terminal.\n\nNotice the console output for errors, manual intervention and tweaks might be required.\n\n\n## Usage (jscodeshift)\n\nTo make the process as simple as possible, we recommend the `jest-codemods` CLI\nthat wraps the [jscodeshift](https://github.com/facebook/jscodeshift) executable.\nBut you can also run the transformations directly using `jscodeshift`.\n\n```\n$ npm install -g jscodeshift\n$ npm install jest-codemods\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/ava.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/chai-assert.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/chai-should.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/expect-js.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/expect.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/jasmine-globals.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/jasmine-this.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/mocha.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/should.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/tape.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/sinon.js test-folder\n$ jscodeshift -t node_modules/jest-codemods/dist/transformers/jest-globals-import.js test-folder\n```\n\n## Test environment: Jest on Node.js or other\n\nIf you're using Jest as your test runner and executing tests on Node.js, you'll want to use\nthe default option when prompted. In this case, `jest-codemods` assumes that global values\nsuch as `expect` and `jest` are provided and will not `require()` them explicitly.\n\nIf, however, you are using a different test runner or executing Jest tests in a browser,\nyou may need to choose the option with explicit `require()` calls.\n\nIn the second case, after running `jest-codemods`, you might need to install a few dependencies:\n\n    yarn add --dev expect jest-mock\n\n    npm install --save-dev expect jest-mock\n\n    pnpm install --save-dev expect jest-mock\n\n\n## Transformations\n\nIf possible `import` / `require` statements determine if any transformation are carried out.\nThe original code quoting style is preserved.\nWarnings are made if packages are used that are incompatible with Jest.\n\n\n## Inspiration\n\nThanks to [avajs/ava-codemods](https://github.com/avajs/ava-codemods) for inspiration and original CLI setup.\n\nThe Mocha and Chai assert support began its life at [paularmstrong/mocha-to-jest-codemod](https://github.com/paularmstrong/mocha-to-jest-codemod).\n\nChai Should/Expect came from [AlexJuarez/chai-to-jasmine](https://github.com/AlexJuarez/chai-to-jasmine).\n\n\n## Links\n\n- Official Jest migration guide https://jestjs.io/docs/en/migration-guide\n- \"Migrating 2,000+ Specs from Karma to Jest\" https://labs.contactually.com/migrating-2-000-specs-from-karma-to-jest-25dd8b0f3cfb\n- \"Into the Great Unknown — Migrating from Mocha to Jest\" https://ebaytech.berlin/into-the-great-unknown-migrating-from-mocha-to-jest-3baced083c7e\n- \"Automate your migration to Jest using codemods\" Egghead video https://egghead.io/lessons/jest-automate-your-migration-to-jest-using-codemods\n- \"Migrating Ava to Jest\" https://codedaily.io/tutorials/11/Migrating-Ava-to-Jest\n- \"Switching from Ava to Jest for TypeScript\" https://shift.infinite.red/switching-from-ava-to-jest-for-typescript-a6dac7d1712f\n- \"Migrating a Mocha project to Jest Test Framework\" https://medium.com/@liran.tal/migrating-a-mocha-project-to-jest-test-framework-76d13d76685\n- \"Migrating to Jest on the P2P team at PayPal\" https://blog.kentcdodds.com/migrating-to-jest-881f75366e7e\n\n\n## Contributing\n\nTo get started, run:\n\n\tpnpm install\n\nWhen developing:\n\n\tpnpm verify  # (build/lint/test)\n\tpnpm build\n\tpnpm lint\n\tpnpm test\n\tpnpm test:cov\n\tpnpm test:watch\n\n\n## License\n\nMIT\n\n[version-badge]: https://img.shields.io/npm/v/jest-codemods.svg?style=flat-square\n[package]: https://www.npmjs.com/package/jest-codemods\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskovhus%2Fjest-codemods","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskovhus%2Fjest-codemods","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskovhus%2Fjest-codemods/lists"}