generated from tophat/new-project-kit
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pretty diff of failed snapshot assertions (#86)
* refactor: move diff generation into serializer * wip: python difflib * wip: use colored library and show some diff context * wip: fix setup py * wip: simplify diff lines * wip: highlight deleted snapshots * wip: highlight changed snapshot lines * refactor: streamline some logic * refactor: fix single line * test: snapshot test diff output * test: snapshot color changing diff * test: make more robust Co-authored-by: Noah <noahnu@gmail.com>
- Loading branch information
Showing
10 changed files
with
234 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from typing import Union | ||
|
||
def attr(color: Union[str, int]) -> str: ... | ||
def bg(color: Union[str, int]) -> str: ... | ||
def fg(color: Union[str, int]) -> str: ... | ||
def stylize(text: Union[str, int], style: str, reset: bool = True) -> str: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# name: test_failing_snapshots_diff | ||
' | ||
|
||
snapshot = SnapshotAssertion(name='snapshot', num_executions=1) | ||
|
||
def test_updated_1(snapshot): | ||
> assert snapshot == ['this', 'will', 'not', 'match'] | ||
E AssertionError: assert snapshot == received | ||
E ... | ||
E - 'be', | ||
E - 'updated', | ||
E + 'not', | ||
E + 'match', | ||
E ... | ||
|
||
test_file.py:17: AssertionError | ||
|
||
snapshot = SnapshotAssertion(name='snapshot', num_executions=1) | ||
|
||
def test_updated_2(snapshot): | ||
> assert ['this', 'will', 'fail'] == snapshot | ||
E AssertionError: assert received == snapshot | ||
E ... | ||
E + 'fail', | ||
E - 'be', | ||
E - 'updated', | ||
E ... | ||
|
||
test_file.py:22: AssertionError | ||
|
||
snapshot = SnapshotAssertion(name='snapshot', num_executions=1) | ||
|
||
def test_updated_3(snapshot): | ||
> assert snapshot == ['this', 'will', 'be', 'too', 'much'] | ||
E AssertionError: assert snapshot == received | ||
E ... | ||
E - 'updated', | ||
E + 'too', | ||
E + 'much', | ||
E ... | ||
|
||
test_file.py:27: AssertionError | ||
|
||
snapshot = SnapshotAssertion(name='snapshot', num_executions=1) | ||
|
||
def test_updated_4(snapshot): | ||
> assert snapshot == "sing line changeling" | ||
E AssertionError: assert snapshot == received | ||
E - 'single line change' | ||
E + 'sing line changeling' | ||
|
||
test_file.py:32: AssertionError | ||
|
||
snapshot = SnapshotAssertion(name='snapshot', num_executions=1) | ||
|
||
def test_updated_5(snapshot): | ||
> assert snapshot == ''' | ||
multiple line changes | ||
with some lines not staying the same | ||
intermittent changes so unchanged lines have to be ignored by the differ | ||
cause when there are a lot of changes you only want to see what changed | ||
you do not want to see this line | ||
or this line | ||
this line should show up because it changes color | ||
and this line does not exist in the first one | ||
''' | ||
E assert snapshot == received | ||
E ... | ||
E - with some lines staying the same | ||
E + with some lines not staying the same | ||
E - intermittent changes that have to be ignore by the differ output | ||
E + intermittent changes so unchanged lines have to be ignored by the differ | ||
E - because when there are a lot of changes you only want to see changes | ||
E + cause when there are a lot of changes you only want to see what changed | ||
E ... | ||
E - [38;5;1mthis line should show up because it changes color[0m | ||
E + [38;5;3mthis line should show up because it changes color[0m | ||
E + and this line does not exist in the first one | ||
E ... | ||
|
||
test_file.py:37: AssertionError | ||
' | ||
--- |
Oops, something went wrong.