Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/jest-snapshot/src/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class SnapshotState {
if (!pass) {
this.unmatched++;
return {
actual: receivedSerialized,
actual: receivedSerialized.replace(/\\"/g, '"'),
Copy link
Contributor

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

count,
expected,
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor

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.

pass: false,
Expand Down