-
-
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
Opt-out special char escaping in result diff #5660
Comments
Ok, landed the option to pretty-format. Now, we need to figure out some way to allow us to pass that option down to it (via |
IMO this should a custom matcher, with that you can pass the option directly to jest-diff |
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. |
What
At the moment jest will always escape special char
\
in diff output of the failed test and replace it with\\
. I would love to have an option to disable this.Having a test like this:
(note that
console.log(str)
will outputa\nb
)Message is:
And the desired output would be:
Why
In my test suite, diff will print a valid javascript.
It's about a library to write custom parsers. Example test is like this:
Function
pretty
takes a tree of js objects and returns a string that is a valid javascript.When expected tree structure is complicated, it's very handy to start with empty expectation:
And copy-paste one from test failure message:
However, at the moment, there is no way jest can print
\n
in that message, because it will always escape it into\\n
.Posible solution
Make escaping of a special chars optional in pretty-format and introduce an option in jest that would be passed to that line of code.
The text was updated successfully, but these errors were encountered: