Codemod verified
Regularly tested and maintained by our engineers and codemod expert community.
Mocha
migration
byCodemod
Mocha/Vitest/Migrate Config
Last update
Jul 24, 2024
Run this codemod to upgrade configuration files that need to be changed after migrating from mocha
to vitest
.
Example
package.json
Before
{"name": "package-name","dependencies": {"mocha": "^10.2.0","some-mocha-plugin": "^10.0.4"},"devDependencies": {"mocha": "^10.2.0","@types/mocha": "^10.0.4"},"main": "./dist/index.cjs","scripts": {"test": "mocha"},"mocha": {"config-key": "config-value"},"files": ["README.md", ".codemodrc.json", "./dist/index.cjs"],"type": "module"}
After
{"name": "package-name","dependencies": {},"devDependencies": {"vitest": "^1.0.1","@vitest/coverage-v8": "^1.0.1"},"main": "./dist/index.cjs","scripts": {"test": "vitest run","coverage": "vitest run --coverage"},"files": ["README.md", ".codemodrc.json", "./dist/index.cjs"],"type": "module"}
tsconfig.json
Before
{"compilerOptions": { "types": ["mocha"] },"include": ["./src/**/*.ts","./src/**/*.js","./test/**/*.ts","./test/**/*.js"]}
After
{"compilerOptions": {},"include": ["./src/**/*.ts","./src/**/*.js","./test/**/*.ts","./test/**/*.js"]}
.mocharc
Before
{"loader": ["ts-node/esm"],"full-trace": true,"failZero": false,"bail": true,"spec": "./**/test.ts","timeout": 5000}
After
Removed
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community