Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug: npx create-typescript-app failed to migrate tests #1355

Open
3 tasks done
danvk opened this issue Feb 28, 2024 · 3 comments
Open
3 tasks done

🐛 Bug: npx create-typescript-app failed to migrate tests #1355

danvk opened this issue Feb 28, 2024 · 3 comments
Labels
status: in discussion Not yet ready for implementation or a pull request type: bug Something isn't working :(

Comments

@danvk
Copy link
Contributor

danvk commented Feb 28, 2024

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

I expected npx create-typescript-app to migrate my tests from Jest to vitest as described in https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/docs/Migration.md

Actual

The tests were not migrated.

Based on the "Required" but un-run statuses in this PR branch, I think I may be in some kind of bad state?
danvk/literate-ts#246

It doesn't look like I have any workflow that would run my repo's tests, for example.

Additional Info

There were no errors relating to tests when I ran npx create-typescript-app. The logs are below.

┌  ✨ Welcome to create-typescript-app 1.52.7! ✨
│
│  ⚠️ This template is early stage, opinionated, and not endorsed by the TypeScript team. ⚠️
│  ⚠️ If any tooling it sets displeases you, you can always remove that portion manually. ⚠️
│
◇  How would you like to use the template?
│  migrate the existing repository in the current directory
│
◇  What organization or user will the repository be under?
│  danvk
│
◇  What will the kebab-case name of the repository be?
│  literate-ts
│
◇  ✅ Passed checking GitHub authentication.
│
◇  How would you describe the new package?
│  Code samples that scale
│
◇  What will the Title Case title of the repository be?
│  Literate TS
│
◇  ✅ Passed migrating repository structure.
│
◇  ✅ Passed initializing GitHub repository.
│
◇  ✅ Passed installing packages.
│
◇  ✅ Passed cleaning up files.
│
│  🟡 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.
│
└  Great, looks like the script finished! 🎉

You may consider committing these changes:

git add -A
git commit -m "migrated repo to create-typescript-app ✨
git push

See ya! 👋

│
●  Tip: to run again with the same input values, use: npx create-typescript-app --mode migrate --base minimum --access public --author danvk --description "Code samples that scale" --directory literate-ts --email-github danvdk@gmail.com --email-npm danvdk@gmail.com --mode migrate --owner danvk --repository literate-ts --title "Literate TS"
@danvk danvk added the type: bug Something isn't working :( label Feb 28, 2024
@JoshuaKGoldberg
Copy link
Owner

...huh, interesting! Just to confirm, I think I can spot at least the following two issues:

  • 🍏 .github/workflows/test.yml wasn't created, but should have been
  • 🍌 Tests still use Jest syntax, but should have been migrated to Vitest

For 🍏 the test workflow, that seems like a straightforward bug and what I think you're pointing at. Accepting PRs!

For 🍌 migrating tests from Jest to Vitest, I'm not positive that that's actually what you're asking about. But it's something I've been back-of-mind thinking about... unfortunately there's no good migrator that I know of, and making one could be super complex. I think it'd be better to leave that as a followup issue for logging a message suggesting folks use one.

Was there anything else missing @danvk?

@JoshuaKGoldberg JoshuaKGoldberg added the status: accepting prs Please, send a pull request to resolve this! label Mar 5, 2024
@danvk
Copy link
Contributor Author

danvk commented Mar 5, 2024

If migrating from Jest → Vitest is hard and out of scope, that's fine. My suggestion then would be to make the create-typescript-app script fail and reset the repo if it detects Jest, to force you to migrate to Vitest manually.

I'd also suggest removing this text from the Migration docs:

For example, if the repository previously using Jest for testing:

  • eslint-plugin-jest, jest, and other Jest-related packages will be uninstalled
  • Any Jest config file like jest.config.js will be deleted
  • eslint-plugin-vitest, vitest, and other Vitest-related packages will be installed
  • A vitest.config.ts file will be created
  1. Given my experience, I don't think the migration script actually does those things?
  2. It doesn't say it, but I kind of read "and your tests will be migrated" since otherwise you'd be in a bad state?

So stepping back, maybe my request would be for the docs to explain what I'm expected to do with my existing Jest tests before or after I run the migration script.

@JoshuaKGoldberg JoshuaKGoldberg added status: in discussion Not yet ready for implementation or a pull request and removed status: accepting prs Please, send a pull request to resolve this! labels Mar 7, 2024
@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Mar 7, 2024

Filed #1375 for the docs callout. 👍

I don't think the migration script actually does those things?

Aha, I think I see the issue!

●  Tip: to run again with the same input values, use: npx create-typescript-app --mode migrate --base minimum --access public --author danvk --description "Code samples that scale" --directory literate-ts --email-github danvdk@gmail.com --email-npm danvdk@gmail.com --mode migrate --owner danvk --repository literate-ts --title "Literate TS"

Specifically: --base minimum

That's a bug. It should have at least asked you what --base to use before giving you the least-useful minimum. Filed #1376.

Btw, I set up a standalone repro in https://github.com/JoshuaKGoldberg/repros/tree/create-typescript-app-jest-to-vitest-migration. In case it's useful.

Is there anything else we should change? I'm splitting out issues to keep the comment histories cleaner, and adding Co-authored-by.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in discussion Not yet ready for implementation or a pull request type: bug Something isn't working :(
Projects
None yet
Development

No branches or pull requests

2 participants