create-typescript-app icon indicating copy to clipboard operation
create-typescript-app copied to clipboard

πŸš€ Feature: Migration should call out needing to migrate non-Vitest tests to Vitest

Open JoshuaKGoldberg opened this issue 1 year ago β€’ 1 comments

Bug Report Checklist

  • [X] I have pulled the latest main branch of the repository.
  • [X] I have searched for related issues and found none that matched my issue.

Overview

Splitting out of #1355: migration markets itself to be a one-stop-shop solution for aligning an existing repo to this template. But when run on an existing repository with tests written in a non-Vitest testing library (e.g. Jest), the actual test files aren't migrated over to Vitest. This leads to broken expectations with users.

The migration script should let the user know they need to migrate their tests manually.

Proposal: if Mocha or Jest was previously in the repository, add another 🟑 note similar to the existing ones?

β”‚  🟑 Running `pnpm lint --fix` failed. You should run it and fix its complaints.
β”‚  🟑 Running `pnpm format --write` failed. You should run it and fix its complaints.

Note that there's no automatic migrator command/project that can be referenced. Building one would be quite complex, and likely impossible to get fully right. Vitest's Migrating from Jest docsΒ is probably the best place we can send Vitest users.

Maybe good phrasing would look something like the following?

  • Jest: 🟑 You'll need to manually migrate your Jest tests to Vitest. See https://vitest.dev/guide/migration.html#migrating-from-jest for more information.
  • Mocha: 🟑 You'll need to manually migrate your Mocha tests to Vitest.

...where if detection for other test frameworks is added, it'd use the same template as Mocha?

Additional Info

It's tempting to suggest running pnpm test to know whether to generate the 🟑... but unit tests might take a very long time and/or have unintended side effects. That's not something we should do for the user.

Co-authored-by: @danvk

JoshuaKGoldberg avatar Mar 07 '24 15:03 JoshuaKGoldberg

It's probably really out-of-date now, but I've used vitest-codemod in the past with mixed success.

lishaduck avatar May 13 '25 00:05 lishaduck