Skip to content

Commit

Permalink
1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mjclawar committed May 15, 2018
1 parent 9720a2f commit 9fbef41
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# CHANGELOG

## 1.2.0 - 2018-05-15
### Changed
- Improves clarity of error messages for large component comparisons
##### Old logic:
raise `AssertionError` with large string difference between JSON objects if the component did not match the snapshot, which led to difficult to read error message like:
```
AssertionError: {'pro[136 chars]en': 'another one'}, 'namespace': 'dash_html_c[77 chars]Div'} != {'pro[136 chars]en': [1, 2, 3]}, 'namespace': 'dash_html_compo[73 chars]Div'}
```
##### New logic:
raise `AssertionError` with large string difference between JSON objects if the component does not match the snapshot, **and**
add new details section about the **first local mismatch** between the component and snapshot:
```
DETAILS:
<class 'list'> != <class 'str'>
CONTEXT 1:
{"children": [1, 2, 3]}
CONTEXT 2:
{"children": "another one"}
```
or
```
DETAILS:
P != Span
CONTEXT 1:
{"type": "P", "props": {"children": "another one"}, "namespace": "dash_html_components"}
CONTEXT 2:
{"type": "Span", "props": {"children": "another one"}, "namespace": "dash_html_components"}
```

## 1.1.0 - 2018-04-11
### Added
- This package now checks for an environment variable (UPDATE_DASH_SNAPSHOTS) and will automatically overwrite snapshots if it is set to TRUE
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name='dash-snapshot-testing',
version='1.1.0',
version='1.2.0',
author='Michael Clawar, Eric Linden',
author_email='tech@stratodem.com',
packages=['snapshot_test'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"namespace": "dash_html_components", "type": "Div", "props": {"children": [{"namespace": "dash_html_components", "type": "P", "props": {"children": "wow"}}, {"namespace": "dash_html_components", "type": "Span", "props": {"children": "another one"}}], "id": "test-id"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"namespace": "dash_html_components", "type": "Div", "props": {"children": [{"namespace": "dash_html_components", "type": "P", "props": {"children": "wow!"}}, {"namespace": "dash_html_components", "type": "Span", "props": {"children": "this works"}}], "id": "test-id"}}
13 changes: 13 additions & 0 deletions snapshot_test/__tests__/test_snapshot_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,16 @@ def test_component_2(self):
self.assertRaises(
AssertionError,
lambda: self.assertSnapshotEqual(my_component, 'my-test-unique-id'))

def test_component_3(self):
my_component = html.Div([html.P('wow'), html.Span([1, 2, 3])], id='test-id')

self.assertRaises(
AssertionError,
lambda: self.assertSnapshotEqual(my_component, 'my-test-unique-id'))

my_component = html.Div([html.P('wow'), html.Span((1, 2, 3))], id='test-id')

self.assertRaises(
AssertionError,
lambda: self.assertSnapshotEqual(my_component, 'my-test-unique-id'))

0 comments on commit 9fbef41

Please sign in to comment.