vitest-codemod
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

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 run clear-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.

Package Sidebar

Install

npm i vitest-codemod

Weekly Downloads

8

Version

0.1.3

License

MIT

Unpacked Size

13.7 kB

Total Files

17

Last publish

Collaborators

  • trivikr