File tree Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Expand file tree Collapse file tree 2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 44
55### 1. Generate Baseline Snapshots
66
7- First, generate baseline snapshots from a commit before your changes :
7+ First, generate baseline snapshots from some other revision :
88
99``` bash
10- # Generate baseline from latest origin/ main (most common)
11- npm run visual:baseline -- --main
10+ # From main (most common)
11+ npm run visual:baseline
1212
1313# Or from a specific commit hash
1414npm run visual:baseline -- abc123
@@ -17,7 +17,13 @@ npm run visual:baseline -- abc123
1717npm run visual:baseline -- HEAD~1
1818```
1919
20- This will check out that revision in a git work tree, run the visual snapshot tests, and copy the snapshots back into your current working directory.
20+ This will check out that revision in a git worktree in a temp dir, run the
21+ visual snapshot tests, and copy the snapshots back into your current working
22+ directory.
23+
24+ Note that this command does not fetch anything from the remote repo; it uses
25+ whatever you have locally. If you want to make sure you have the latest ` main ` ,
26+ you need to pull it first.
2127
2228### 2. Compare Current Changes
2329
Original file line number Diff line number Diff line change @@ -10,10 +10,9 @@ set -euo pipefail
1010PROJECT_ROOT=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
1111cd " $PROJECT_ROOT "
1212
13- echo " Fetching latest from origin..."
14- git fetch origin main --quiet
13+ REV=${1:- main}
1514
16- COMMIT=$( git rev-parse origin/main )
15+ COMMIT=$( git rev-parse " $REV " )
1716WORKTREE_DIR=$( mktemp -d -t visual-baseline-XXXXXX)
1817
1918cleanup () {
@@ -22,7 +21,7 @@ cleanup() {
2221}
2322trap cleanup EXIT INT TERM
2423
25- echo " Creating worktree at origin/main ($COMMIT )..."
24+ echo " Creating worktree at $REV ($COMMIT )..."
2625git worktree add --detach " $WORKTREE_DIR " " $COMMIT " --quiet
2726
2827echo " Copying test files..."
@@ -35,7 +34,7 @@ echo "Installing dependencies..."
3534npm ci
3635
3736echo " Generating baseline snapshots..."
38- npx playwright test --config=playwright.visual.config.ts --project=chrome -- update-snapshots
37+ npx playwright test --config=playwright.visual.config.ts --update-snapshots
3938
4039echo " Copying snapshots back..."
4140cp -r test/visual/regression.e2e.ts-snapshots " $PROJECT_ROOT /test/visual/"
You can’t perform that action at this time.
0 commit comments