-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Prettier is used by toMatchInlineSnapshot
, but it is not a dependency of jest
#8467
Comments
This is expected. @azz might remember the particulars |
Would you expect jest to bundle some version and defer to a local one? Related #7792 |
Hmm. Not sure; thanks for the context. Maybe it should be listed as a peerdep? A descriptive error message saying "you need to install prettier" might be good enough, too. It's unexpected to get a "could not find prettier" error the first time you use Not sure if this makes sense for jest, but prettier could be replaced with babel + recast here, and it could use prettier for printing (instead of recast) as an optimization, when it's available. |
There's a bunch of discussion in the original PR #6380, especially #6380 (comment). The main thing we wanna avoid is to completely butcher the styling of the test file creating churn. Using prettier assures we're consistent with the current styling, which is nice. Not sure how well using recast would work? It might work great without butchering existent styling at all for all I know 🙂 |
Yup, that's what it's designed for 👍 recast keeps track of which AST nodes have been changed and only prints those ones using original styling. It uses the original source for all the other nodes. You can defer its parsing to another parser, so babel could be used to ensure all the necessary syntax and etc is supported. |
Oh, nice!
yeah, we should definitely to that as a first step regardless. #7744 |
I just ran into this as well. |
Still no progress? |
Maybe the error message should at least state that |
looks like it is supposed to throw a descriptive error message: The error message that I get with
|
Edit: Crossed out test, error has been resolved in Jest v27 (#11400) |
@HunterKohler This should be fixed in Jest v27 (#11400) What version are you using? |
@UziTech My bad! It is fixed, just had to update dependencies. Thank you. |
This issue hasn't been fixed, I still get an error.
|
I think this is fine now that prettier is optional, as mentioned a few times above. If people are still having issues please create a new issue. |
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. |
🐛 Bug Report
Prettier is used by jest for
toMatchInlineSnapshot
, but since it's not a dependency ofjest
,toMatchInlineSnapshot
only works if some other package depends on prettier (or it's in the user'spackage.json
).To Reproduce
Steps to reproduce the behavior:
yarn init --yes
inside ityarn add jest
toMatchInlineSnapshot
matcher, eg:Expected behavior
Test passes with no issues
npx envinfo --preset jest
System: OS: macOS 10.14.4 CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz Binaries: Node: 12.1.0 - /usr/local/bin/node Yarn: 1.13.0 - /usr/local/bin/yarn npm: 6.9.0 - /usr/local/bin/npm npmPackages: jest: 24.8.0 => 24.8.0
The text was updated successfully, but these errors were encountered: