You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/testing.md
+12-17Lines changed: 12 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -169,31 +169,26 @@ If you are interested in how we write tests, see the [tests/](https://github.com
169
169
170
170
## Snapshot testing
171
171
172
-
A _snapshot_ is a record of what an application looked like at a given point in time.
172
+
Snapshot testing is the process of recording the output of a test, and comparing it against the output from previous runs.
173
173
174
-
_Snapshot testing_ is the process of creating a snapshot of an application while a test runs, and comparing it to a historical version.
175
-
If there's a mismatch, the snapshot testing framework flags it for review.
174
+
Textual uses snapshot testing internally to ensure that the builtin widgets look and function correctly in every release.
175
+
We've made the pytest plugin we built available for public use.
176
176
177
-
This offers a simple, automated way of checking our application displays like we expect.
177
+
The [official pytest plugin](https://github.com/Textualize/pytest-textual-snapshot) can help you catch otherwise difficult to detect visual changes in your app.
178
178
179
-
### pytest-textual-snapshot
179
+
It works by generating an SVG _screenshot_ (such as the images in these docs) from your app.
180
+
If the screenshot changes in any test run, you will will have the opertunity to visually compare the new output against previous runs.
180
181
181
-
You can use [`pytest-textual-snapshot`](https://github.com/Textualize/pytest-textual-snapshot) to snapshot test your Textual app.
182
-
This is a plugin for pytest which adds support for snapshot testing Textual apps, and it's maintained by the developers of Textual.
183
182
184
-
A test using this package saves a snapshot (in this case, an SVG screenshot) of a running Textual app to disk.
185
-
The next time the test runs, it takes another snapshot and compares it to the previously saved one.
186
-
If the snapshots differ, the test fails, and you can view a side-by-side diff showing the visual change.
187
-
188
-
#### Installation
183
+
### Installing the plugin
189
184
190
185
You can install `pytest-textual-snapshot` using your favorite package manager (`pip`, `poetry`, etc.).
191
186
192
187
```
193
188
pip install pytest-textual-snapshot
194
189
```
195
190
196
-
####Creating a snapshot test
191
+
### Creating a snapshot test
197
192
198
193
With the package installed, you now have access to the `snap_compare` pytest fixture.
199
194
@@ -248,7 +243,7 @@ pytest --snapshot-update
248
243
Now that our snapshot is saved, if we run `pytest` (with no arguments) again, the test will pass.
249
244
This is because the screenshot taken during this test run matches the one we saved earlier.
250
245
251
-
####Catching a bug
246
+
### Catching a bug
252
247
253
248
The real power of snapshot testing comes from its ability to catch visual regressions which could otherwise easily be missed.
254
249
@@ -274,7 +269,7 @@ our new developer has also deleted the number 4!
274
269
report is just an HTML file which can be exported as a build artifact.
275
270
276
271
277
-
####Pressing keys
272
+
### Pressing keys
278
273
279
274
You can simulate pressing keys before the snapshot is captured using the `press` parameter.
0 commit comments