Skip to content

Commit 9fbff13

Browse files
branchseerclaude
andcommitted
feat(tests): add inline comments to snapshot tests and fix test issues
- Add inline shell comments (# explanation) to all e2e test steps so they appear in generated snapshots for better readability - Fix shared-caching-inputs: correct comments to reflect actual cache behavior (script2 gets cache hit from script1's identical command) - Fix vite-task-smoke: correct comments (main.js IS an input file) - Fix individual-cache-for-envs: add vite.config.json with envs config so different env values actually get separate cache entries - Fix colon-in-name: rename test from "task with underscore in name" to "read file with colon in name" and delete stale snapshot - Add file header comments explaining test purpose Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c295754 commit 9fbff13

File tree

53 files changed

+270
-223
lines changed

Some content is hidden

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

53 files changed

+270
-223
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# Tests that tasks with identical commands share cache
2+
13
[[e2e]]
24
name = "associate existing cache"
35
steps = [
4-
"vite run script1",
5-
"vite run script2",
6-
"json-edit package.json '_.scripts.script2 = \"print world\"'",
7-
"vite run script2",
6+
"vite run script1 # cache miss",
7+
"vite run script2 # cache hit, same command as script1",
8+
"json-edit package.json '_.scripts.script2 = \"print world\"' # change script2",
9+
"vite run script2 # cache miss",
810
]

crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache/snapshots/associate existing cache.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ assertion_line: 203
44
expression: e2e_outputs
55
input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/associate-existing-cache
66
---
7-
> vite run script1
7+
> vite run script1 # cache miss
88
$ print hello
99
hello
1010

@@ -22,7 +22,7 @@ Task Details:
2222
Cache miss: no previous cache entry found
2323
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2424

25-
> vite run script2
25+
> vite run script2 # cache hit, same command as script1
2626
$ print hellocache hit, replaying
2727
hello
2828

@@ -40,9 +40,9 @@ Task Details:
4040
→ Cache hit - output replayed - <duration> saved
4141
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4242

43-
> json-edit package.json '_.scripts.script2 = "print world"'
43+
> json-edit package.json '_.scripts.script2 = "print world"' # change script2
4444

45-
> vite run script2
45+
> vite run script2 # cache miss
4646
$ print world ✗ cache miss: args changed, executing
4747
world
4848

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# Tests that builtin commands have separate cache per cwd
2+
13
[[e2e]]
24
name = "builtin different cwd"
35
steps = [
4-
"cd folder1 && vite lint",
5-
"cd folder2 && vite lint",
6-
"echo 'console.log(1);' > folder2/a.js",
7-
"cd folder1 && vite lint",
8-
"cd folder2 && vite lint",
6+
"cd folder1 && vite lint # cache miss in folder1",
7+
"cd folder2 && vite lint # cache miss in folder2",
8+
"echo 'console.log(1);' > folder2/a.js # modify folder2",
9+
"cd folder1 && vite lint # cache hit",
10+
"cd folder2 && vite lint # cache miss",
911
]

crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd/snapshots/builtin different cwd.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ assertion_line: 203
44
expression: e2e_outputs
55
input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/builtin-different-cwd
66
---
7-
> cd folder1 && vite lint
7+
> cd folder1 && vite lint # cache miss in folder1
88

99
! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
1010
,-[a.js:1:1]
@@ -17,7 +17,7 @@ Found 1 warning and 0 errors.
1717
Finished in <duration> on 1 file with 90 rules using <n> threads.
1818
1919
20-
> cd folder2 && vite lint
20+
> cd folder2 && vite lint # cache miss in folder2
2121
2222
! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
2323
,-[a.js:1:1]
@@ -30,9 +30,9 @@ Found 1 warning and 0 errors.
3030
Finished in <duration> on 1 file with 90 rules using <n> threads.
3131
3232
33-
> echo 'console.log(1);' > folder2/a.js
33+
> echo 'console.log(1);' > folder2/a.js # modify folder2
3434
35-
> cd folder1 && vite lint
35+
> cd folder1 && vite lint # cache hit
3636
✓ cache hit, replaying
3737
3838
! eslint-plugin-unicorn(no-empty-file): Empty files are not allowed.
@@ -46,7 +46,7 @@ Found 1 warning and 0 errors.
4646
Finished in <duration> on 1 file with 90 rules using <n> threads.
4747
4848
49-
> cd folder2 && vite lint
49+
> cd folder2 && vite lint # cache miss
5050
✗ cache miss: content of input 'folder2/a.js' changed, executing
5151
Found 0 warnings and 0 errors.
5252
Finished in <duration> on 1 file with 90 rules using <n> threads.
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
# Tests that cache: false in task config disables caching
2+
13
[[e2e]]
24
name = "task with cache disabled"
35
steps = [
4-
"vite run no-cache-task",
5-
"vite run no-cache-task",
6+
"vite run no-cache-task # cache miss",
7+
"vite run no-cache-task # cache disabled, runs again",
68
]
79

810
[[e2e]]
911
name = "task with cache enabled"
1012
steps = [
11-
"vite run cached-task",
12-
"vite run cached-task",
13+
"vite run cached-task # cache miss",
14+
"vite run cached-task # cache hit",
1315
]

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache disabled.snap

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
source: crates/vite_task_bin/tests/test_snapshots/main.rs
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
assertion_line: 203
34
expression: e2e_outputs
4-
input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-disabled
5+
input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled
56
---
6-
> vite run no-cache-task
7+
> vite run no-cache-task # cache miss
78
$ print-file test.txtcache disabled: no cache config
89
test content
910

@@ -21,7 +22,7 @@ Task Details:
2122
Cache disabled in task configuration
2223
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2324

24-
> vite run no-cache-task
25+
> vite run no-cache-task # cache disabled, runs again
2526
$ print-file test.txtcache disabled: no cache config
2627
test content
2728

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled/snapshots/task with cache enabled.snap

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
source: crates/vite_task_bin/tests/test_snapshots/main.rs
2+
source: crates/vite_task_bin/tests/e2e_snapshots/main.rs
3+
assertion_line: 203
34
expression: e2e_outputs
4-
input_file: crates/vite_task_bin/tests/test_snapshots/fixtures/cache-disabled
5+
input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-disabled
56
---
6-
> vite run cached-task
7+
> vite run cached-task # cache miss
78
$ print-file test.txt
89
test content
910

@@ -21,7 +22,7 @@ Task Details:
2122
Cache miss: no previous cache entry found
2223
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2324

24-
> vite run cached-task
25+
> vite run cached-task # cache hit
2526
$ print-file test.txtcache hit, replaying
2627
test content
2728

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# Tests cache behavior when command changes partially
2+
13
[[e2e]]
24
name = "cache miss command change"
35
steps = [
4-
"vite run task",
5-
"json-edit package.json '_.scripts.task = \"print baz && print bar\"'",
6-
"vite run task",
7-
"json-edit package.json '_.scripts.task = \"print bar\"'",
8-
"vite run task",
6+
"vite run task # cache miss",
7+
"json-edit package.json '_.scripts.task = \"print baz && print bar\"' # change first subtask",
8+
"vite run task # first: cache miss, second: cache hit",
9+
"json-edit package.json '_.scripts.task = \"print bar\"' # remove first subtask",
10+
"vite run task # cache hit",
911
]

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change/snapshots/cache miss command change.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ assertion_line: 203
44
expression: e2e_outputs
55
input_file: crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-command-change
66
---
7-
> vite run task
7+
> vite run task # cache miss
88
$ print foo
99
foo
1010

@@ -28,9 +28,9 @@ Task Details:
2828
Cache miss: no previous cache entry found
2929
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3030

31-
> json-edit package.json '_.scripts.task = "print baz && print bar"'
31+
> json-edit package.json '_.scripts.task = "print baz && print bar"' # change first subtask
3232

33-
> vite run task
33+
> vite run task # first: cache miss, second: cache hit
3434
$ print bazcache miss: args changed, executing
3535
baz
3636

@@ -54,9 +54,9 @@ Task Details:
5454
→ Cache hit - output replayed - <duration> saved
5555
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
5656

57-
> json-edit package.json '_.scripts.task = "print bar"'
57+
> json-edit package.json '_.scripts.task = "print bar"' # remove first subtask
5858

59-
> vite run task
59+
> vite run task # cache hit
6060
$ print bar ✓ cache hit, replaying
6161
bar
6262

crates/vite_task_bin/tests/e2e_snapshots/fixtures/cache-miss-reasons/snapshots.toml

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,55 @@
33
[[e2e]]
44
name = "env value changed"
55
steps = [
6-
# Initial run
7-
"cross-env MY_ENV=1 vite run test",
8-
# Cache miss: env value changed
9-
"cross-env MY_ENV=2 vite run test",
6+
"cross-env MY_ENV=1 vite run test # cache miss",
7+
"cross-env MY_ENV=2 vite run test # cache miss: env value changed",
108
]
119

1210
[[e2e]]
1311
name = "env added"
1412
steps = [
15-
# Initial run without env
16-
"vite run test",
17-
# Cache miss: env added
18-
"cross-env MY_ENV=1 vite run test",
13+
"vite run test # cache miss",
14+
"cross-env MY_ENV=1 vite run test # cache miss: env added",
1915
]
2016

2117
[[e2e]]
2218
name = "env removed"
2319
steps = [
24-
# Initial run with env
25-
"cross-env MY_ENV=1 vite run test",
26-
# Cache miss: env removed
27-
"vite run test",
20+
"cross-env MY_ENV=1 vite run test # cache miss",
21+
"vite run test # cache miss: env removed",
2822
]
2923

3024
[[e2e]]
3125
name = "pass-through env added"
3226
steps = [
33-
"vite run test",
34-
# Add pass-through env
35-
"json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\"",
36-
# Cache miss: pass-through env added
37-
"vite run test",
27+
"vite run test # cache miss",
28+
"json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\" # add pass-through env",
29+
"vite run test # cache miss: pass-through env added",
3830
]
3931

4032
[[e2e]]
4133
name = "pass-through env removed"
4234
steps = [
43-
# Setup: task with pass-through env
44-
"json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\"",
45-
"vite run test",
46-
# Remove pass-through env
47-
"json-edit vite.config.json \"delete _.tasks.test.passThroughEnvs\"",
48-
# Cache miss: pass-through env removed
49-
"vite run test",
35+
"json-edit vite.config.json \"_.tasks.test.passThroughEnvs = ['MY_PASSTHROUGH']\" # setup",
36+
"vite run test # cache miss",
37+
"json-edit vite.config.json \"delete _.tasks.test.passThroughEnvs\" # remove pass-through env",
38+
"vite run test # cache miss: pass-through env removed",
5039
]
5140

5241
[[e2e]]
5342
name = "cwd changed"
5443
steps = [
55-
"vite run test",
56-
# Create subfolder and copy test.txt there
44+
"vite run test # cache miss",
5745
"mkdir -p subfolder",
5846
"cp test.txt subfolder/test.txt",
59-
# Change cwd to subfolder
60-
"json-edit vite.config.json \"_.tasks.test.cwd = 'subfolder'\"",
61-
# Cache miss: working directory changed
62-
"vite run test",
47+
"json-edit vite.config.json \"_.tasks.test.cwd = 'subfolder'\" # change cwd",
48+
"vite run test # cache miss: cwd changed",
6349
]
6450

6551
[[e2e]]
6652
name = "input content changed"
6753
steps = [
68-
"vite run test",
69-
# Modify input file
70-
"replace-file-content test.txt initial modified",
71-
# Cache miss: input content changed
72-
"vite run test",
54+
"vite run test # cache miss",
55+
"replace-file-content test.txt initial modified # modify input",
56+
"vite run test # cache miss: input changed",
7357
]

0 commit comments

Comments
 (0)