Skip to content
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

Ignore indentation of data structures in jest-diff #3429

Merged
merged 19 commits into from
Aug 31, 2017
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
57706fa
Ignore indentation in jest-diff
pedrottimark May 1, 2017
78c8308
Ignore indentation in structuredPatch and test it more
pedrottimark May 3, 2017
c793c8a
Merge branch 'master' to see if Prettier 1.3 in 3444 causes merge con…
pedrottimark May 3, 2017
b1980c0
Fix regression for multiline string from toBe or toEqual
pedrottimark May 3, 2017
18063a3
Add snapshot option and make spacing consistent for --expand
pedrottimark May 8, 2017
a0bb73c
Merge branch 'master' into ignore-indentation-diff to resolve merge c…
pedrottimark Jun 27, 2017
9096b7b
Ignore indentation only in compareObjects not in snapshots
pedrottimark Jun 28, 2017
d4af07f
Resolve merge conflicts with 3965 and 4152
pedrottimark Aug 16, 2017
6931b9c
Format lines that are equal except for indentation in cyan color
pedrottimark Aug 22, 2017
87209b9
Edit code after proof reading
pedrottimark Aug 23, 2017
7c4ddc2
Merge master to resolve merge conflicts with 4314
pedrottimark Aug 23, 2017
c6b3a21
Fix misplaced className prop in React elements test
pedrottimark Aug 24, 2017
5f2afb4
Edit code and comments after rereading
pedrottimark Aug 24, 2017
b027601
Factor elementSymbol out of diff test cases
pedrottimark Aug 28, 2017
14e3ff7
Merge branch 'master' into ignore-indentation-diff to upgrade Flow fr…
pedrottimark Aug 28, 2017
bebf76a
Add tests for color of text and background color of spaces
pedrottimark Aug 28, 2017
f178db0
Rewrite tests for color to eliminate duplicate snapshots
pedrottimark Aug 29, 2017
787e124
Make requested changes especially space in second column
pedrottimark Aug 30, 2017
519019f
Edit redundant comments
pedrottimark Aug 30, 2017
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
40 changes: 20 additions & 20 deletions integration_tests/__tests__/__snapshots__/failures.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ exports[`works with node assert 1`] = `
- Expected
+ Received

Object {
\\"a\\": Object {
\\"b\\": Object {
- \\"c\\": 6,
+ \\"c\\": 5,
},
},
}
Object {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's suspicious that these are indented less by one space now. Why was this change made? It makes "Object" not line up with "Received" any longer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This space or no space confused me for a long while. We can go either way. Your choice!

Before this pull request the result changed according to CLI option:

  • default --no-expand option uses hunk format from diff with no space between the first column marker and the actual line
  • --expand option formatted the chunk lines from diff with a space there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize that it was different based on cli options, it shouldn't be! I think two spaces (make it line up with "Received") makes more sense, and it would be good to be consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it better too. To make double sure I understand:

  • The first column consists of -/+/space for removed/added/unchanged
  • The second column consists of space to separate from line content and align with legend

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! The first column may be empty space as well.

\\"a\\": Object {
\\"b\\": Object {
- \\"c\\": 6,
+ \\"c\\": 5,
},
},
}

at __tests__/node_assertion_error.test.js:40:10

Expand All @@ -178,14 +178,14 @@ exports[`works with node assert 1`] = `
- Expected
+ Received

Object {
\\"a\\": Object {
\\"b\\": Object {
- \\"c\\": 7,
+ \\"c\\": 5,
},
},
}
Object {
\\"a\\": Object {
\\"b\\": Object {
- \\"c\\": 7,
+ \\"c\\": 5,
},
},
}

at __tests__/node_assertion_error.test.js:44:10

Expand Down Expand Up @@ -247,10 +247,10 @@ exports[`works with node assert 1`] = `
- Expected
+ Received

Object {
- \\"a\\": 2,
+ \\"a\\": 1,
}
Object {
- \\"a\\": 2,
+ \\"a\\": 1,
}

at __tests__/node_assertion_error.test.js:60:10

Expand Down
92 changes: 87 additions & 5 deletions packages/jest-diff/src/__tests__/__snapshots__/diff.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`background color of spaces cyan for inchanged (expanded) 1`] = `
"<green>- Expected</>
<red>+ Received</>

<dim> <div>
<red>+ <p></>
<cyan> <span></>
<cyan> following string consists of a space:</>
<cyan> <bgCyan> </></>
<cyan> <bgCyan> </>line has preceding space only</>
<cyan> <bgCyan> </>line has both preceding and following space<bgCyan> </></>
<cyan> line has following space only<bgCyan> </></>
<cyan> </span></>
<red>+ </p></>
<dim> </div>"
`;

exports[`background color of spaces green for removed (expanded) 1`] = `
"<green>- Expected</>
<red>+ Received</>

<dim> <div>
<dim> <span>
<green>- following string consists of a space:</>
<green>- <bgGreen> </></>
<green>- <bgGreen> </>line has preceding space only</>
<green>- <bgGreen> </>line has both preceding and following space<bgGreen> </></>
<green>- line has following space only<bgGreen> </></>
<red>+ </>
<dim> </span>
<dim> </div>"
`;

exports[`background color of spaces no color for unchanged (expanded) 1`] = `
"<green>- Expected</>
<red>+ Received</>

<dim> <div>
<green>- <span></>
<red>+ <p></>
<dim> following string consists of a space:
<dim>
<dim> line has preceding space only
<dim> line has both preceding and following space
<dim> line has following space only
<green>- </span></>
<red>+ </p></>
<dim> </div>"
`;

exports[`background color of spaces red for added (expanded) 1`] = `
"<green>- Expected</>
<red>+ Received</>

<dim> <div>
<dim> <span>
<green>- </>
<red>+ following string consists of a space:</>
<red>+ <bgRed> </></>
<red>+ <bgRed> </>line has preceding space only</>
<red>+ <bgRed> </>line has both preceding and following space<bgRed> </></>
<red>+ line has following space only<bgRed> </></>
<dim> </span>
<dim> </div>"
`;

exports[`collapses big diffs to patch format 1`] = `
"<green>- Expected</>
<red>+ Received</>
Expand All @@ -17,6 +83,22 @@ exports[`collapses big diffs to patch format 1`] = `
<dim> }"
`;

exports[`color of text (expanded) 1`] = `
"<green>- Expected</>
<red>+ Received</>

<dim> Object {
<dim> \\"searching\\": \\"\\",
<green>- \\"sorting\\": Object {</>
<red>+ \\"sorting\\": Array [</>
<red>+ Object {</>
<cyan> \\"descending\\": false,</>
<cyan> \\"fieldKey\\": \\"what\\",</>
<cyan> },</>
<red>+ ],</>
<dim> }"
`;

exports[`context number of lines: -1 (5 default) 1`] = `
"<green>- Expected</>
<red>+ Received</>
Expand Down Expand Up @@ -94,11 +176,11 @@ exports[`falls back to not call toJSON if objects look identical 1`] = `
<green>- Expected</>
<red>+ Received</>

<dim> <dim>Object {
<green>-</> <green> \\"line\\": 1,</>
<red>+</> <red> \\"line\\": 2,</>
<dim> <dim> \\"toJSON\\": [Function toJSON],
<dim> <dim>}"
<dim> Object {
<green>- \\"line\\": 1,</>
<red>+ \\"line\\": 2,</>
<dim> \\"toJSON\\": [Function toJSON],
<dim> }"
`;

exports[`prints a fallback message if two objects truly look identical 1`] = `"<dim>Compared values have no visual difference."`;
Loading