-
Notifications
You must be signed in to change notification settings - Fork 826
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
Snapshot testing #793
Snapshot testing #793
Conversation
- name: Upload snapshot report | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: snapshot-report-textual | ||
path: tests/snapshot_tests/output/snapshot_report.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This runs on both failure and success. On success, there's no snapshot report, but the step still succeeds.
test-snapshot-update: | ||
pytest --cov-report term-missing --cov=textual tests/ -vv --snapshot-update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this runs all tests, it'll update all snapshots.
@@ -0,0 +1,43 @@ | |||
# Snapshot Testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal docs
@@ -48,13 +48,15 @@ pre-commit = "^2.13.0" | |||
pytest-aiohttp = "^1.0.4" | |||
time-machine = "^2.6.0" | |||
Jinja2 = "<3.1.0" | |||
syrupy = "^3.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the snapshot testing library we're wrapping which handles associating pytest test functions with snapshots on disk.
|
||
[tool.black] | ||
includes = "src" | ||
|
||
[tool.pytest.ini_options] | ||
asyncio_mode = "auto" | ||
testpaths = ["tests"] | ||
addopts = "--strict-markers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this should be the default - if you use an undefined marker it'll fail fast - good for catching typos.
@@ -0,0 +1,30 @@ | |||
def test_grid_layout_basic(snap_compare): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A selection of layout related tests to get us started.
Adds snapshot testing features to the test suite, and a set of layout-related example tests. We can craft better example apps to do snapshots on in the future.
Basic view:
After toggling the "show difference" switch:
Link to the report will be written to your terminal in the event of a snapshot mismatch:
If you're running in CI, it'll be saved as a build artifact which you can download and view: