Skip to content

Commit 6cd9cd3

Browse files
committed
fix(tests): stop e2e:updateSnaps swallowing its filter, and rebuilding twice
Two papercuts hit while regenerating baselines for the fix in this PR: - vitest declares the flag as `-u, --update [type]` - an *optional* value, which also accepts `new`/`all`/`none`. So in `--run -u <filter>`, cac reads <filter> as the value of `-u`: the filter is dropped and the whole suite silently runs in update mode. `e2e:updateSnaps` ended in `-u`, so any filter a caller appends (as CLAUDE.md instructs) landed in exactly that trap - which quietly rewrote an unrelated, flaky `deleteShallowerBlock` baseline to a wrong value. Attaching the value as `--update=true` makes it unambiguous, so filters stay filters. - wasm-pack emits `packages/xl-typst-compiler/pkg/package.json`, which the image content hash globbed, so building the wasm that docker-run.sh itself requires invalidated the image. A fresh clone paid two full image builds. `pkg` is now pruned alongside `dist`.
1 parent 645886b commit 6cd9cd3

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

.claude/skills/testing-skill/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bash tests/docker-run.sh -e CI=1 -- --run [filters]
5555

5656
A specific test file may be targeted by appending (part of) its name as a filter. A single browser may be targeted with `--project "e2e (chromium)"`. Individual tests in a file may be disabled using `skip`, i.e. `test.skip("Test name", ...)` (remember to revert this once all tests pass).
5757

58-
Screenshot baselines can be regenerated with the `-u` argument, which must come **after** the filters (`--run <filters> -u`): written as `--run -u <filter>`, the filter is parsed as the flag's value and the **whole** suite runs in update mode, silently rewriting unrelated baselines. Note that `-u` only rewrites baselines whose comparison **fails** — a small intended change (e.g. a short text edit) that fits inside the suite's 2% pixel tolerance leaves the baseline stale while the test passes. To force a fresh capture, delete the baseline file first. Baselines are per-browser (`<name>-<browser>-linux.png`); after regenerating, always inspect the images before committing them.
58+
Screenshot baselines can be regenerated with `--update=true` (as `e2e:updateSnaps` does). Always attach the value: vitest declares the flag as `-u, --update [type]` (it also accepts `new`/`all`/`none`), so a bare `-u` before a filter swallows the filter as its value and silently runs the **whole** suite in update mode. `--update=true` cannot, so filters stay filters in any position. Note that `-u` only rewrites baselines whose comparison **fails** — a small intended change (e.g. a short text edit) that fits inside the suite's 2% pixel tolerance leaves the baseline stale while the test passes. To force a fresh capture, delete the baseline file first. Baselines are per-browser (`<name>-<browser>-linux.png`); after regenerating, always inspect the images before committing them.
5959

6060
When testing a visual change, prefer writing screenshots to verify that the change is working as expected.
6161

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"install-playwright": "cd tests && vp exec playwright install --with-deps",
2828
"e2e:image": "bash tests/docker-build.sh",
2929
"e2e": "bash tests/docker-run.sh -e CI=1 -- --run",
30-
"e2e:updateSnaps": "bash tests/docker-run.sh -e CI=1 -- --run -u",
30+
"e2e:updateSnaps": "bash tests/docker-run.sh -e CI=1 -- --run --update=true",
3131
"e2e:report": "serve -l 4173 tests/playwright-report",
3232
"lint": "vp lint --type-aware",
3333
"typecheck": "tsc --noEmit -p tsconfig.json",

tests/docker-run.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ entrypoint_args=("$@")
2929
# Auto-rebuild the image if its content hash label doesn't match the current
3030
# repo state. The hash covers every file that affects the image's contents: the
3131
# Dockerfile itself, plus everything it bakes in — the lockfile, workspace file,
32-
# all package.json files, patches, and example sources. When they differ the
32+
# all package.json files, patches, and example sources. Generated output dirs
33+
# are pruned: `pkg/` is wasm-pack's, and it emits a package.json, so without
34+
# that prune, building the wasm this script *requires* would itself invalidate
35+
# the image and force a second full rebuild. When they differ the
3336
# image is rebuilt in place
3437
# (Docker's layer cache makes this fast when only a leaf changed).
3538
_dep_files() {
@@ -42,7 +45,8 @@ _dep_files() {
4245
find . -name package.json \
4346
-not -path '*/node_modules/*' \
4447
-not -path '*/.git/*' \
45-
-not -path '*/dist/*'
48+
-not -path '*/dist/*' \
49+
-not -path '*/pkg/*'
4650
} | sort -u
4751
}
4852
_content_hash() {

0 commit comments

Comments
 (0)