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

fix: Error if prettier@3 is used for inline snapshots #14367

Merged
merged 3 commits into from
Jul 27, 2023

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Jul 27, 2023

Summary

As mentioned in #14311 (comment), we're currently blocked on supporting v3 properly. I think it's better to throw an explicit error for users pointing to docs with a workaround.

Test plan

E2E test added

@netlify
Copy link

netlify bot commented Jul 27, 2023

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit d1b6024
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/64c231c96459a400086b3e1a
😎 Deploy Preview https://deploy-preview-14367--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -1144,6 +1144,37 @@ Default: `'prettier'`

Sets the path to the [`prettier`](https://prettier.io/) node module used to update inline snapshots.

Note that Prettier version 3 is not supported. You can either pass `prettierPath: null` in your config to disable using prettier if you don't need it, or use v2 of Prettier solely for Jest.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've forgotten to roll 29.6 docs - will do so after landing this

Copy link
Contributor

@mrazauskas mrazauskas Jul 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about wrapping this block in some :::info admonition?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps like this:

<details>
  <summary>Prettier version 3 is not supported!</summary>
  Etc...
</details>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh, details look great! didn't know docusaurus formatted it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! details is a rarely useful feature, but for my eye it’s just perfect in this case.

@SimenB SimenB merged commit 2092927 into jestjs:main Jul 27, 2023
@SimenB SimenB deleted the prettier-3-reject branch July 27, 2023 09:15
wincent added a commit to wincent/masochist that referenced this pull request Aug 2, 2023
Sadly, Prettier v3 breaks inline snapshots:

   FAIL  packages/legacy/src/parser/__tests__/parse-test.ts
    ● Test suite failed to run

      Jest: Inline Snapshots are not supported when using Prettier 3.0.0 or above.
      See https://jestjs.io/docs/configuration/#prettierpath-string for alternatives.

        at saveInlineSnapshots (node_modules/jest-snapshot/build/InlineSnapshots.js:101:15)

So, as noted in:

- jestjs/jest#14367

set `prettierPath` in the Jest config, install v2 just for use by Jest,
update the snapshots, which now have an, um, prettier format, like this:

    -       "selections": Array [
    -         Object {
    +       "selections": [
    +         {

and then re-run Prettier manually with `yarn format` to make sure that
everything remains stable.
@github-actions
Copy link

This pull request 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 Aug 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants