Skip to content

Commit c6bda70

Browse files
committed
testing words
1 parent 9eb7b4c commit c6bda70

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

docs/guide/testing.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,31 +169,26 @@ If you are interested in how we write tests, see the [tests/](https://github.com
169169

170170
## Snapshot testing
171171

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.
173173

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.
176176

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.
178178

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.
180181

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.
183182

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
189184

190185
You can install `pytest-textual-snapshot` using your favorite package manager (`pip`, `poetry`, etc.).
191186

192187
```
193188
pip install pytest-textual-snapshot
194189
```
195190

196-
#### Creating a snapshot test
191+
### Creating a snapshot test
197192

198193
With the package installed, you now have access to the `snap_compare` pytest fixture.
199194

@@ -248,7 +243,7 @@ pytest --snapshot-update
248243
Now that our snapshot is saved, if we run `pytest` (with no arguments) again, the test will pass.
249244
This is because the screenshot taken during this test run matches the one we saved earlier.
250245

251-
#### Catching a bug
246+
### Catching a bug
252247

253248
The real power of snapshot testing comes from its ability to catch visual regressions which could otherwise easily be missed.
254249

@@ -274,7 +269,7 @@ our new developer has also deleted the number 4!
274269
report is just an HTML file which can be exported as a build artifact.
275270

276271

277-
#### Pressing keys
272+
### Pressing keys
278273

279274
You can simulate pressing keys before the snapshot is captured using the `press` parameter.
280275

@@ -283,7 +278,7 @@ def test_calculator_pressing_numbers(snap_compare):
283278
assert snap_compare("path/to/calculator.py", press=["1", "2", "3"])
284279
```
285280

286-
#### Changing the terminal size
281+
### Changing the terminal size
287282

288283
To capture the snapshot with a different terminal size, pass a tuple `(width, height)` as the `terminal_size` parameter.
289284

@@ -292,7 +287,7 @@ def test_calculator(snap_compare):
292287
assert snap_compare("path/to/calculator.py", terminal_size=(50, 100))
293288
```
294289

295-
#### Running setup code
290+
### Running setup code
296291

297292
You can also run arbitrary code before the snapshot is captured using the `run_before` parameter.
298293

docs/index.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ hide:
44
- navigation
55
---
66

7+
!!! tip inline end
78

8-
# Welcome
9+
See the navigation links in the header or side-bar.
910

10-
Welcome to the [Textual](https://github.com/Textualize/textual) framework documentation.
11+
Click :octicons-three-bars-16: (top left) on mobile.
1112

12-
!!! tip
1313

14-
See the navigation links in the header or side-bars. Click the :octicons-three-bars-16: button (top left) on mobile.
14+
# Welcome
1515

16+
Welcome to the [Textual](https://github.com/Textualize/textual) framework documentation.
1617

1718
[Get started](./getting_started.md){ .md-button .md-button--primary } or go straight to the [Tutorial](./tutorial.md)
1819

0 commit comments

Comments
 (0)