vitest-codemod
v0.1.3
Published
Codemod scripts to migrate your JavaScript unit tests to vitest
Downloads
426
Maintainers
Readme
vitest-codemod
This repository contains a collection of codemod scripts for use with JSCodeshift that help migrate to vitest.
The vitest-codemod
CLI is a lightweight wrapper over jscodeshift.
It processes --help
, --version
and --transform
options before passing them
downstream.
Prerequisites
To use vitest-codemod, please install Node.js.
Usage
- Optionally execute dry-run for the transform, and print transformed files on stdout:
npx vitest-codemod --dry --print -t jest PATH...
- Run transform, and make changes to files:
npx vitest-codemod -t jest PATH...
- To use the latest version of vitest-codemod, clear your npx cache. You can either
manually delete folder
$(npm get cache)/_npx/*
, or runclear-npx-cache
.npx clear-npx-cache
Example
$ cat example.spec.js
describe("basic", () => {
test("Math.sqrt()", () => {
expect(Math.sqrt(4)).toBe(2);
})
});
$ npx vitest-codemod -t jest example.spec.js
$ cat example.spec.js
import { describe, expect, test } from "vitest";
describe("basic", () => {
test("Math.sqrt()", () => {
expect(Math.sqrt(4)).toBe(2);
})
});
License
This library is licensed under the MIT License. See the LICENSE file.