JoshuaKGoldberg / JoshuaKGoldberg/create-typescript-app
🚀 Feature: Migration should call out needing to migrate non-Vitest tests to Vitest
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 89
- Avg merge
- 1m
- Merged PRs (30d)
- 3
Description
### Bug Report Checklist
- [X] I have pulled the latest `main` branch of the repository.
- [X] I have [searched for related issues](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aissue) 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?
```plaintext
│ 🟡 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](https://vitest.dev/guide/migration.html#migrating-from-jest) 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
Contributor guide
Assessment
This issue has not been assessed yet.