Recommend pretty-format library provided by jest #2929
Comments
|
Doesn't jest run |
|
I'm not sure. I can test next week. |
|
At the least, it calls Prettier: https://github.com/facebook/jest/blob/5d1e98beda19dcfff3f10557396098524efbb639/packages/jest-snapshot/src/inline_snapshots.ts#L42 |
|
It seems to format it when I pass an element to the expect function. It doesn't format a string (e.g. |
I think that would be fine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was going through the testing recipes and noticed that the documentation recommends a npm module for pretty printing HTML for snapshot: https://reactjs.org/docs/testing-recipes.html#snapshot-testing.
The package is this: https://www.npmjs.com/package/pretty. There is another, imo stronger candidate to replace this package, which is pretty-format. Why would this be better? Its part of jest and the example code in the documentation is already using jest. Therefor it would be better to recommend a dependency from a source that the reader is already more likely to be using other dependencies from (which in this case is jest).
You can pretty print HTML with pretty-format like so:
The text was updated successfully, but these errors were encountered: