fix: Error if prettier@3 is used for inline snapshots#14367
Conversation
✅ Deploy Preview for jestjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
|
||
| 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. |
There was a problem hiding this comment.
I've forgotten to roll 29.6 docs - will do so after landing this
There was a problem hiding this comment.
What about wrapping this block in some :::info admonition?
There was a problem hiding this comment.
Or perhaps like this:
<details>
<summary>Prettier version 3 is not supported!</summary>
Etc...
</details>There was a problem hiding this comment.
ooh, details look great! didn't know docusaurus formatted it
There was a problem hiding this comment.
There was a problem hiding this comment.
Looks good! details is a rarely useful feature, but for my eye it’s just perfect in this case.
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.
|
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. |
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