Agent Skillsdyad-sh/dyad › dyad:debug-with-playwright

dyad:debug-with-playwright

GitHub

用于调试基于Playwright的E2E测试,通过在关键步骤手动添加截图来可视化检查应用状态,解决Electron环境下自动截图失效的问题。

.claude/skills/debug-with-playwright/SKILL.md dyad-sh/dyad

Trigger Scenarios

需要调试E2E测试失败原因 需要在特定UI状态下获取截图

Install

npx skills add dyad-sh/dyad --skill dyad:debug-with-playwright -g -y
More Options

Non-standard path

npx skills add https://github.com/dyad-sh/dyad/tree/main/.claude/skills/debug-with-playwright -g -y

Use without installing

npx skills use dyad-sh/dyad@dyad:debug-with-playwright

指定 Agent (Claude Code)

npx skills add dyad-sh/dyad --skill dyad:debug-with-playwright -a claude-code -g -y

安装 repo 全部 skill

npx skills add dyad-sh/dyad --all -g -y

预览 repo 内 skill

npx skills add dyad-sh/dyad --list

SKILL.md

Frontmatter
{
    "name": "dyad:debug-with-playwright",
    "description": "Debug E2E tests by taking screenshots at key points to visually inspect application state."
}

Debug with Playwright Screenshots

Debug E2E tests by taking screenshots at key points to visually inspect application state.

Arguments

  • $ARGUMENTS: (Optional) Specific E2E test file to debug (e.g., main.spec.ts or e2e-tests/main.spec.ts). If not provided, will ask the user which test to debug.

Background

Dyad uses Electron + Playwright for E2E tests. Because Playwright's built-in screenshot: "on" option does NOT work with Electron (see https://github.com/microsoft/playwright/issues/8208), you must take screenshots manually via page.screenshot().

The test fixtures in e2e-tests/helpers/fixtures.ts already auto-capture a screenshot on test failure and attach it to the test report. But for debugging, you often need screenshots at specific points during test execution.

Instructions

  1. Identify the test to debug:

    If $ARGUMENTS is empty, ask the user which test file they want to debug.

    • If provided without the e2e-tests/ prefix, add it
    • If provided without the .spec.ts suffix, add it
  2. Read the test file:

    Read the test file to understand what it does and where it might be failing.

  3. Add debug screenshots to the test:

    Add page.screenshot() calls at key points in the test to capture visual state. Access the page from the po fixture:

    // Get the page from the electronApp fixture
    const page = await electronApp.firstWindow();
    
    // Or if you only have `po`, access the page directly:
    // po is a PageObject which has a `page` property
    

    Screenshot patterns for debugging:

    import * as fs from "fs";
    import * as path from "path";
    
    // Create a debug screenshots directory
    const debugDir = path.join(__dirname, "debug-screenshots");
    if (!fs.existsSync(debugDir)) {
      fs.mkdirSync(debugDir, { recursive: true });
    }
    
    // Take a full-page screenshot
    await page.screenshot({
      path: path.join(debugDir, "01-before-action.png"),
    });
    
    // Take a screenshot of a specific element
    const element = page.locator('[data-testid="chat-input"]');
    await element.screenshot({
      path: path.join(debugDir, "02-chat-input.png"),
    });
    
    // Take a screenshot after some action
    await po.sendPrompt("hi");
    await page.screenshot({
      path: path.join(debugDir, "03-after-send.png"),
    });
    

    Important: The test fixture signature provides { electronApp, po }. To get the page:

    • Use await electronApp.firstWindow() to get the page
    • Or use po.page if PageObject exposes it

    Add screenshots before and after the failing step to understand what the UI looks like at that point.

  4. Build the app (if needed):

    E2E tests run against the built binary. If you made any application code changes:

    npm run build
    

    If you only changed test files, you can skip this step.

  5. Run the test:

    PLAYWRIGHT_RETRIES=0 PLAYWRIGHT_HTML_OPEN=never npm run e2e -- e2e-tests/<testfile>.spec.ts
    
  6. View the screenshots:

    Use the Read tool to view the captured PNG screenshots. Claude Code can read and display images directly:

    Read the PNG files in e2e-tests/debug-screenshots/
    

    Analyze the screenshots to understand:

    • Is the expected UI element visible?
    • Is there an error dialog or unexpected state?
    • Is a loading spinner still showing?
    • Is the layout correct?
  7. Check the Playwright trace (for additional context):

    The Playwright config has trace: "retain-on-failure". If the test failed, a trace file will be in test-results/. You can reference this for additional debugging context.

  8. Iterate:

    Based on what you see in the screenshots:

    • Add more targeted screenshots if needed
    • Fix the issue in the test or application code
    • Re-run to verify
  9. Clean up:

    After debugging is complete, remove the debug screenshots and any temporary screenshot code you added to the test:

    rm -rf e2e-tests/debug-screenshots/
    

    Remove any page.screenshot() calls you added for debugging purposes.

  10. Report findings:

    Tell the user:

    • What the screenshots revealed about the test failure
    • What fix was applied (if any)
    • Whether the test now passes

Version History

  • 7158f6f Current 2026-08-20 16:42

Same Skill Collection

.claude/skills/add-models/SKILL.md
.claude/skills/check-workflows/SKILL.md
.claude/skills/debug-minified-error/SKILL.md
.claude/skills/deflake-e2e-from-run/SKILL.md
.claude/skills/deflake-e2e-recent-commits/SKILL.md
.claude/skills/deflake-e2e/SKILL.md
.claude/skills/e2e-rebase/SKILL.md
.claude/skills/feedback-to-issues/SKILL.md
.claude/skills/fix-issue/SKILL.md
.claude/skills/plan-to-issue/SKILL.md
.claude/skills/pr-fix-ci/SKILL.md
.claude/skills/pr-fix-comments/SKILL.md
.claude/skills/pr-fix/SKILL.md
.claude/skills/pr-push/SKILL.md
.claude/skills/pr-rebase/SKILL.md
.claude/skills/pr-screencast/SKILL.md
.claude/skills/promote-beta-to-stable/SKILL.md
.claude/skills/remember-learnings/SKILL.md
.claude/skills/swarm-pr-review/SKILL.md
.claude/skills/swarm-to-plan/SKILL.md
.claude/skills/multi-pr-review/SKILL.md

Metadata

Files
0
Version
157ab55
Hash
fbc59707
Indexed
2026-08-20 16:42

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-30 01:06
浙ICP备14020137号-1 $Гость$