Skip to content

Commit 2a14bc1

Browse files
committed
tests - document skip field and snapshot testing in README
1 parent 8b7e13e commit 2a14bc1

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,19 @@ ok | 1 passed | 0 failed (2s)
223223

224224
Smoke-all tests support metadata in the `_quarto.tests.run` key to control when tests are run:
225225

226+
- Skip test unconditionally:
227+
228+
```yaml
229+
_quarto:
230+
tests:
231+
run:
232+
skip: true # Skip with default message
233+
skip: "Reason for skipping this test" # Skip with custom message
234+
```
235+
236+
Use this when a test needs to be temporarily disabled while an issue is being investigated,
237+
or when a test is pending an upstream fix. Include a descriptive message explaining why.
238+
226239
- Skip tests on CI:
227240
228241
```yaml
@@ -257,6 +270,27 @@ Valid OS values are: `linux`, `darwin` (macOS), `windows`
257270

258271
This is useful when tests require platform-specific dependencies or have known platform-specific issues that need separate investigation.
259272

273+
##### Snapshot testing
274+
275+
Use `ensureSnapshotMatches` to compare rendered output against a saved snapshot file:
276+
277+
```yaml
278+
_quarto:
279+
tests:
280+
html:
281+
ensureSnapshotMatches: []
282+
```
283+
284+
The snapshot file should be saved alongside the output with a `.snapshot` extension (e.g., `output.html.snapshot`).
285+
286+
When a snapshot test fails:
287+
- A **unified diff** is displayed with colored output (red for removed, green for added)
288+
- A **word-level diff** shows changes with surrounding context
289+
- For **whitespace-only changes**, special markers visualize invisible characters:
290+
- `` for newlines, `→` for tabs, `·` for spaces
291+
- A `.diff` file is saved next to the output for later inspection
292+
- The `.diff` file is automatically cleaned up when the snapshot passes
293+
260294
### Limitations
261295

262296
- `smoke-all.test.ts` accept only one argument. You need to use glob pattern to run several smoke-all test documents.

0 commit comments

Comments
 (0)