home / skills / dyad-sh / dyad / e2e-rebase

e2e-rebase skill

/.claude/skills/e2e-rebase

This skill helps you rebase e2e test snapshots by extracting failed tests from PR comments and updating snapshots accordingly.

npx playbooks add skill dyad-sh/dyad --skill e2e-rebase

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.0 KB
---
name: dyad:e2e-rebase
description: Rebase E2E test snapshots based on failed tests from the PR comments.
---

# E2E Snapshot Rebase

Rebase E2E test snapshots based on failed tests from the PR comments.

## Instructions

1. Get the current PR number using `gh pr view --json number --jq '.number'`

2. Fetch PR comments and look for the Playwright test results comment. Parse out the failed test filenames from either:
   - The "Failed Tests" section (lines starting with `- \`filename.spec.ts`)
   - The "Update Snapshot Commands" section (contains `npm run e2e e2e-tests/filename.spec.ts`)

3. If no failed tests are found in the PR comments, inform the user and stop.

4. **Build the application binary:**

   ```
   npm run build
   ```

   **IMPORTANT:** E2E tests run against the built binary. If any application code (anything outside of `e2e-tests/`) has changed, you MUST run this build step before running E2E tests, otherwise you'll be testing the old version.

5. For each failed test file, run the e2e test with snapshot update:

   ```
   PLAYWRIGHT_HTML_OPEN=never npm run e2e e2e-tests/<testFilename>.spec.ts -- --update-snapshots
   ```

6. After updating snapshots, re-run the same tests WITHOUT `--update-snapshots` to verify they pass consistently:

   ```
   PLAYWRIGHT_HTML_OPEN=never npm run e2e e2e-tests/<testFilename>.spec.ts
   ```

   If any test fails on this verification run, inform the user that the snapshots may be flaky and stop.

7. Show the user which snapshots were updated using `git diff` on the snapshot files.

8. Review the snapshot changes to ensure they look reasonable and are consistent with the PR's purpose. Consider:
   - Do the changes align with what the PR is trying to accomplish?
   - Are there any unexpected or suspicious changes?

9. If the snapshots look reasonable, commit and push the changes:

   ```
   git add e2e-tests/snapshots/
   git commit -m "Update E2E snapshots"
   git push
   ```

10. Inform the user that the snapshots have been updated and pushed to the PR.

Overview

This skill automates rebasing E2E test snapshots by parsing failing Playwright results posted in PR comments and updating snapshots for the affected tests. It runs targeted commands to update snapshots, verifies the updates, shows diffs, and pushes the changes back to the PR when everything looks correct. The workflow ensures snapshots match the built app version and prevents flaky changes from being committed.

How this skill works

The skill reads the current PR number and scans PR comments for the Playwright test results block. It extracts failed test filenames from either the "Failed Tests" list or the "Update Snapshot Commands" block. For each failed test it builds the app if necessary, updates snapshots via Playwright with the update flag, reruns the test to verify stability, shows git diffs of snapshot files, and if everything is reasonable, commits and pushes the snapshot updates to the PR.

When to use it

  • A PR has Playwright results posted and snapshots failed.
  • You changed UI or behavior that should intentionally update snapshots.
  • You need to rebase snapshots for only the tests that failed.
  • You want to avoid running the entire E2E suite locally.
  • You want automated, targeted snapshot updates tied to the PR.

Best practices

  • Always run the build step first if any non-e2e files changed; snapshots must match the built binary.
  • Inspect git diffs of snapshots to confirm changes align with the PR intent.
  • Re-run updated tests without --update-snapshots to ensure updates are stable.
  • Avoid committing snapshot noise; reject updates that look unrelated or flaky.
  • Run these steps on the same environment that produced the original Playwright output.

Example use cases

  • A PR changes component styling which causes a few E2E snapshot failures — update only those snapshots and push.
  • CI posts Playwright results in a PR; use this skill to parse the comment and rebase the listed snapshots.
  • A contributor updates text content and snapshots need rebasing for specific spec files.
  • You want to quickly verify snapshot updates locally before committing them to the PR.

FAQ

What if no failed tests are found in the PR comments?

The skill stops and informs you. Ensure the Playwright results comment exists and includes either the Failed Tests list or Update Snapshot Commands.

What if a test still fails after updating snapshots?

Stop and inspect: persistent failures suggest flakiness or a mismatch between the app build and tests. Do not commit those snapshot changes until resolved.