Skip to content

Commit

Permalink
explain jest-snapshot double json encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Demedes committed Jan 30, 2017
1 parent 9a27d34 commit 2fa8da9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ x._snapshot = function (tree, optionalMessage, match, snapshotStateGetter) {
let expected;

if (result.expected) {
// JSON in a snapshot is surrounded with `"`
// JSON in a snapshot is surrounded with `"`, because jest-snapshot
// serializes snapshot values too, so it ends up double JSON encoded
expected = JSON.parse(result.expected.slice(1).slice(0, -1));
// Define a `$$typeof` symbol, so that pretty-format detects it as React tree
if (expected.jsx) {
Expand Down

0 comments on commit 2fa8da9

Please sign in to comment.