jest-codemods
jest-codemods is an automated migration tool that converts test files from 10+ testing frameworks (Mocha, Chai, AVA, Tape, Jasmine, Sinon, etc.) to Jest syntax. It uses codemods—small AST-based programs—to perform bulk code transformations, reducing manual effort when adopting Jest.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | skovhus/jest-codemods |
| Owner | skovhus |
| Primary language | TypeScript |
| License | MIT — OSI-approved |
| Stars | 888 |
| Forks | 81 |
| Open issues | 36 |
| Latest release | 0.35.0 (2025-08-13) |
| Last updated | 2026-06-30 |
| Source | https://github.com/skovhus/jest-codemods |
What jest-codemods is
A TypeScript-based jscodeshift wrapper that exposes framework-specific AST transformers for test suite migration. It preserves code quoting style, detects import/require statements to determine applicable transformations, and outputs warnings for incompatible patterns. Designed for Node.js test environments with optional explicit require() support for browser or non-Jest runners.
Get the jest-codemods source
Clone the repository and explore it locally.
git clone https://github.com/skovhus/jest-codemods.gitcd jest-codemods# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Always run with --dry flag first to inspect proposed changes; even with good coverage, some assertions and mocks require manual post-migration fixes.
- Ensure Jest and supporting packages (jest-mock, expect) are installed before running codemods; some transformations insert new imports that assume availability.
- Original code quoting style is preserved, but review for consistency; codemod outputs may mix single/double quotes depending on source files.
- Test against your full suite in a branch; some patterns (complex spy chains, global teardown) may not transform correctly and require manual intervention.
- Use jscodeshift directly for fine-tuned control (e.g., targeting specific files or applying partial transformations).
When to avoid it — and what to weigh
- Heavy custom test utilities — If your test framework wraps assertions or mocking in custom domain-specific utilities, codemods may not recognize or transform them correctly; manual review required.
- Minimal test coverage — For projects with <5 test files or simple, homogeneous test syntax, manual migration is often faster and less error-prone than setting up and validating codemod runs.
- Snapshot or integration test heavy suites — Codemods may incorrectly transform complex mocking, global state, or browser-specific test patterns; visual inspection and rework post-migration is expected.
- Production test runners in browsers — If tests must run in non-Node.js environments without explicit require() support, migration may fail or require significant manual tweaks after codemod execution.
License & commercial use
MIT License. Permissive; allows commercial use, modification, and distribution with attribution. No legal restrictions on commercial deployment.
MIT is a standard permissive OSI license. Commercial use is permitted. No licensing fees, per-seat charges, or proprietary restrictions apply. Verify your own Jest license and test dependencies for any commercial constraints.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
Codemods execute arbitrary AST transformation on local files; only run on trusted or version-controlled codebases. No network communication or external dependency downloads during transformation. Use --dry flag to review changes before committing. Ensure Node.js and jscodeshift are up to date.
Alternatives to consider
Manual migration + linting rules
For small suites or heterogeneous test code, direct refactoring combined with ESLint rules (e.g., eslint-plugin-jest) may be clearer and require less validation.
TypeScript compiler or Babel plugins
If you control test syntax from the start, use Jest's TypeScript support and Babel presets to avoid test framework switching; codemods only needed if locked into legacy frameworks.
IDE refactoring + find-replace
For small migrations or framework-specific edge cases, IDE bulk-replace and multi-file edit often converge faster and with fewer surprises than codemod validation loops.
Build on jest-codemods with DEV.co software developers
Start with a dry run on a feature branch. Use npx jest-codemods to inspect changes, then validate thoroughly before committing. For large multi-framework projects, consider professional migration services.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
jest-codemods FAQ
Do I need to install Jest before running jest-codemods?
What happens to complex mocks or spies?
Can I run jest-codemods on a subset of files?
Are there compatibility issues with Jest?
Custom software development services
DEV.co helps companies turn open-source tools like jest-codemods into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source testing stack.
Ready to migrate your test suite to Jest?
Start with a dry run on a feature branch. Use npx jest-codemods to inspect changes, then validate thoroughly before committing. For large multi-framework projects, consider professional migration services.