Skip to content

Commit d19333d

Browse files
branchseerclaude
andauthored
refactor(test): use markdown for e2e snapshots (#342)
## Motivation Render e2e snapshots as markdown so human review — on GitHub and in editors — benefits from syntax highlighting and structural rendering. The old `.snap` format packed everything into a custom line-prefix convention (`[code]> cmd # comment`) that editors couldn't highlight and diffs had to be read without any visual grouping. Each step is now an `##` section with the command in backticks, comment and optional `**Exit code:**` line, and a fenced code block for the redacted output; interactions are bolded labels interleaved with fenced screen captures; each file opens with an `#` heading carrying the case name. ## Changes - [crates/vite_task_bin/tests/e2e_snapshots/main.rs](crates/vite_task_bin/tests/e2e_snapshots/main.rs): split display_command into command-line + comment accessors; rewrite the interaction-loop and output-formatting blocks to emit markdown; change snapshot extension from .snap to .md; add push_fenced_block helper. - [.gitignore](.gitignore): add *.md.new alongside existing *.snap.new so the mismatch fallback file is ignored. - Regenerated all 148 e2e snapshots in the new format. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2d44be3 commit d19333d

291 files changed

Lines changed: 3572 additions & 1185 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ dist
66
.DS_Store
77
/.vscode/settings.json
88
*.snap.new
9+
*.md.new

crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate_existing_cache/snapshots.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Tests that tasks with identical commands share cache
1+
comment = """
2+
Tests that tasks with identical commands share cache
3+
"""
24

35
[[e2e]]
46
name = "associate_existing_cache"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# associate_existing_cache
2+
3+
Tests that tasks with identical commands share cache
4+
5+
## `vt run script1`
6+
7+
cache miss
8+
9+
```
10+
$ vtt print hello
11+
hello
12+
```
13+
14+
## `vt run script2`
15+
16+
cache hit, same command as script1
17+
18+
```
19+
$ vtt print hello ◉ cache hit, replaying
20+
hello
21+
22+
---
23+
vt run: cache hit.
24+
```
25+
26+
## `vtt replace-file-content package.json '"script2": "vtt print hello"' '"script2": "vtt print world"'`
27+
28+
change script2
29+
30+
```
31+
```
32+
33+
## `vt run script2`
34+
35+
cache miss
36+
37+
```
38+
$ vtt print world ○ cache miss: args changed, executing
39+
world
40+
```

crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate_existing_cache/snapshots/associate_existing_cache.snap

Lines changed: 0 additions & 14 deletions
This file was deleted.

crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin_different_cwd/snapshots.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Tests that synthetic tasks have separate cache per cwd
1+
comment = """
2+
Tests that synthetic tasks have separate cache per cwd
3+
"""
24

35
[[e2e]]
46
name = "builtin_different_cwd"

crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin_different_cwd/snapshots/builtin_different_cwd.snap renamed to crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin_different_cwd/snapshots/builtin_different_cwd.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,45 @@
1-
> vt run cwd1 # cache miss in folder1
1+
# builtin_different_cwd
2+
3+
Tests that synthetic tasks have separate cache per cwd
4+
5+
## `vt run cwd1`
6+
7+
cache miss in folder1
8+
9+
```
210
~/folder1$ vt tool print-cwd
311
<workspace>/folder1
4-
> vt run cwd2 # cache miss in folder2 (different cwd)
12+
```
13+
14+
## `vt run cwd2`
15+
16+
cache miss in folder2 (different cwd)
17+
18+
```
519
~/folder2$ vt tool print-cwd
620
<workspace>/folder2
7-
> vt run cwd1 # cache hit in folder1
21+
```
22+
23+
## `vt run cwd1`
24+
25+
cache hit in folder1
26+
27+
```
828
~/folder1$ vt tool print-cwd ◉ cache hit, replaying
929
<workspace>/folder1
1030
1131
---
1232
vt run: cache hit.
13-
> vt run cwd2 # cache hit in folder2
33+
```
34+
35+
## `vt run cwd2`
36+
37+
cache hit in folder2
38+
39+
```
1440
~/folder2$ vt tool print-cwd ◉ cache hit, replaying
1541
<workspace>/folder2
1642
1743
---
1844
vt run: cache hit.
45+
```

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache_disabled/snapshots.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# Tests that cache: false in task config disables caching
1+
comment = """
2+
Tests that cache: false in task config disables caching
3+
"""
24

35
[[e2e]]
46
name = "task_with_cache_disabled"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# task_with_cache_disabled
2+
3+
Tests that cache: false in task config disables caching
4+
5+
## `vt run no-cache-task`
6+
7+
cache miss
8+
9+
```
10+
$ vtt print-file test.txt ⊘ cache disabled
11+
test content
12+
```
13+
14+
## `vt run no-cache-task`
15+
16+
cache disabled, runs again
17+
18+
```
19+
$ vtt print-file test.txt ⊘ cache disabled
20+
test content
21+
```

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache_disabled/snapshots/task_with_cache_disabled.snap

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# task_with_cache_enabled
2+
3+
Tests that cache: false in task config disables caching
4+
5+
## `vt run cached-task`
6+
7+
cache miss
8+
9+
```
10+
$ vtt print-file test.txt
11+
test content
12+
```
13+
14+
## `vt run cached-task`
15+
16+
cache hit
17+
18+
```
19+
$ vtt print-file test.txt ◉ cache hit, replaying
20+
test content
21+
22+
---
23+
vt run: cache hit.
24+
```

0 commit comments

Comments
 (0)