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

[Feature]: Migrate to Prettier v3 #13495

Closed
sosukesuzuki opened this issue Oct 23, 2022 · 15 comments
Closed

[Feature]: Migrate to Prettier v3 #13495

sosukesuzuki opened this issue Oct 23, 2022 · 15 comments

Comments

@sosukesuzuki
Copy link

sosukesuzuki commented Oct 23, 2022

🚀 Feature Proposal

Hi, I am a maintainer at Prettier.

The Prettier team is currently working on v3 (still alpha).
v3 will include breaking changes. (Detailed changelog is here: https://github.com/prettier/prettier/releases/tag/3.0.0-alpha.1)

For example, the all of public APIs will be async (changelog). Jest inline snapshots will probably be affected by this.

If you have any questions, feel free to mention us. We can help you.

If you have already migrated to Prettier v3, sorry but please close this issue.

Motivation

  • Allow Jest to follow Prettier changes

Example

N/A

Pitch

Jest inline snapshots that uses Prettier as a library, is included in Jest core

@SimenB
Copy link
Member

SimenB commented Oct 23, 2022

Thanks for opening up an issue!

For example, the all of public APIs will be async (changelog). Jest inline snapshots will probably be affected by this.

That means we probably won't ever be able to migrate - I don't think we wanna make snapshot matchers async. We could possibly have some codemod or similar, but I'm not too sure about that...

What we can do is probably just drop the prettier usage in the inline snapshots and solely use the babel approach which was released in Jest 27.

@liuxingbaoyu
Copy link
Contributor

https://github.com/babel/babel/blob/main/packages/babel-register/src/worker/index.js
This may be an option in the future.

By the way, this would be another powerful illustration of the real world for calling async in sync, and I'll probably mention this somewhere.😃
ref: nodejs/node#45018

@SimenB
Copy link
Member

SimenB commented Oct 24, 2022

Using a worker might work, but I think I'd rather avoid it 😅 It's not just a single back and forth, we'd need to load all of jest-snapshot within it, do diffing etc.

If we could preload prettier somehow and then have the APIs be sync it'd work. But I doubt that's something prettier would want

@liuxingbaoyu
Copy link
Contributor

I just noticed that prettier seems to already have something like this, which is great!
https://github.com/prettier/prettier-synchronized

@SimenB
Copy link
Member

SimenB commented Oct 24, 2022

Ah! If that becomes a thing I guess we could use that.

But dropping the runtime (albeit optional) dep on prettier would be preferable I think.

@sosukesuzuki
Copy link
Author

Yes, maybe @prettier/sync would be useful for this purpose. However, if Jest will drop the Prettier usage for inline snapshots you can close this issue.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Nov 24, 2022
@fisker
Copy link
Contributor

fisker commented Nov 24, 2022

Please keep it open.

@github-actions github-actions bot removed the Stale label Nov 24, 2022
@SimenB SimenB added the Pinned label Nov 24, 2022
@fisker
Copy link
Contributor

fisker commented Apr 21, 2023

Can we try to run tests with [email protected] to see what's broken?

@SimenB
Copy link
Member

SimenB commented Apr 21, 2023

Sure! Should be fine to just open a PR upgrading?

@SimenB
Copy link
Member

SimenB commented Jul 5, 2023

Congrats on the release!

Should we use https://github.com/prettier/prettier-synchronized in Jest?

@uncleramsay
Copy link

Prettier v3 has dropped, and this appears to have broken snapshot testing in projects that upgrade. Is there any update on when we can expect to see support?

@mrazauskas
Copy link
Contributor

Prettier v3 has dropped, and this appears to have broken snapshot testing in projects that upgrade.

This is tracked in #14305

@SimenB
Copy link
Member

SimenB commented Nov 27, 2023

Done in #14566

@SimenB SimenB closed this as completed Nov 27, 2023
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants