A collection of useful code migration scripts, currently supporting the following:
- Adding
.js
to your Typescript files; useful when moving an existingcommonjs
project with multiple files to toesmodules
. - Importing
vitest
'stest
anddescribe
functions, and replacingjest.fn()
withvi.fn()
; useful when moving fromjest
tovitest
in an existing project with a lot of test files.
NOTE: modifications may not always be accurate, so it's best to work off a separate branch without any changes, incase you want to revert all changes and run again.
npm install code-migration-helpers -D
npx code-migration-helpers
yarn add code-migration-helpers -D
With code-migration-helpers
, you can add .js
extension to relative imports in all Typescript files in a supplied folder path. To do that, run the following, replacing ../folder/path
with your intended folder's path. Also, look at, and follow the advice in the NOTE above before running.
code-migration-helpers add-js-ext ../folder/path
With code-migration-helpers
, you can import test
and describe
functions, and replace jest.fn()
mock functions with vi.fn()
in all Typescript files in a supplied folder path. To do that, run the following, replacing ../folder/path
with your intended folder's path. Also, look at, and follow the advice in the NOTE above before running.
code-migration-helpers jest-to-vitest ../folder/path