-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Fixes snapshot rendering not to show backslashes #2731
Conversation
20c034d
to
32c9bf5
Compare
Wait, I'm worried this is a hack. Shouldn't this replace "\" with "" (nothing)? cc @vjeux. He is the expert here. |
Can you tell me how to reproduce this? The fix is almost certainly wrong. If you see a |
I know this is hacky and doesn't solve problem entirely, sorry. Just wanted to let you know that there's something weird going on. This will show up like this every time you change a snapshotted string value (at least on my computer). Try changing "unkwon" to something different in this test. And based on the changes made to snapshots by #2482 it escapes the same way. |
I'll close this PR, but let's discuss it further |
@@ -158,7 +158,7 @@ class SnapshotState { | |||
if (!pass) { | |||
this.unmatched++; | |||
return { | |||
actual: receivedSerialized, | |||
actual: receivedSerialized.replace(/\\"/g, '"'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you can use received
@@ -158,7 +158,7 @@ class SnapshotState { | |||
if (!pass) { | |||
this.unmatched++; | |||
return { | |||
actual: receivedSerialized, | |||
actual: receivedSerialized.replace(/\\"/g, '"'), | |||
count, | |||
expected, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the tricky thing is this one. we only have the serialized version. The way we unserialize stuff right now is to eval. So we'd need to eval the expected part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it safe to eval here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, why do we need to eval here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, expected
here is a serialized version. The way you unserialize a snapshot is by doing require('snapshot.js')
which basically evals it.
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
Back to normal snapshot rendering in terminal, without altering new snapshots escaping method.
Test plan
jest