Token导航 LogoToken导航TokenDH.com
开发操作浏览器github未标认证来源可访问许可证需确认审计异常

e2e电子到电子

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

194

周安装

8

GitHub Stars

19

下载量

63
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:e2e(电子到电子)
来源仓库:https://github.com/yusuftayman/playwright-cli-agents
仓库路径:skills/e2e
安装命令:
npx skills add https://github.com/yusuftayman/playwright-cli-agents --skill e2e
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/yusuftayman/playwright-cli-agents --skill e2e

简介

用于端到端测试自动化与用例验证支持。e2e 属于开发类 Skill,可作为该场景下的辅助能力补充。

  • 适合在浏览器环境中运行测试并检查页面行为。
  • 通过 npx 命令安装并使用,需确认项目已集成 Playwright 框架。
  • 安装前建议核实本地环境是否具备浏览器驱动和测试夹具。
  • 使用时注意区分模拟环境与真实业务逻辑,避免误判。

SKILL.md

E2E Test Generator Skill

This skill generates E2E tests using playwright-cli commands for browser automation. It uses the Page Object Model pattern and supports visual regression testing with the @visual tag in test titles.

When to Use

Use this skill when:

  • The user provides a URL to explore and create tests for
  • You need to create new E2E tests for a web application
  • You want to generate Page Object classes for a website
  • Visual regression tests are needed (integrated with integration tests using @visual tag)

Prerequisites

  • playwright-cli installed globally (npm install -g @playwright/cli@latest)
  • Target URL must be accessible
  • Project should have Playwright configured

Workflow Overview

1. EXPLORE → Navigate to URL, take snapshot, understand the page structure
2. PLAN → Identify testable features and create test plan
3. GENERATE PAGES → Create Page Object classes
4. GENERATE TESTS → Create test specs (add @visual tag for visual checks)
5. VALIDATE → Run tests to ensure they pass

References

For detailed exploration techniques and CLI commands, see:

Examples

For code templates and patterns, see:


Quick Start Workflow

Phase 1: URL Exploration

  1. Open URL playwright-cli open https://example.com
  2. Take Page Snapshot playwright-cli snapshot
  3. Identify Interactive Elements from snapshot output:

- Buttons, links, form inputs - Navigation elements - Modal triggers - Dropdown menus

  1. Test Interactions before generating code: playwright-cli click e12 playwright-cli snapshot # Verify result

Phase 2: Test Planning

Based on exploration, identify:

  1. Happy Path Tests - Core user workflows
  2. Edge Cases - Error states, boundary conditions
  3. Visual Tests - UI consistency checks (add @visual tag to test title when needed)

Phase 3: Generate Page Objects

See examples/page-object-model.md for templates.

Key rules:

  • All locators as readonly class properties
  • Initialize locators in constructor
  • Every interaction method has waitFor before action
  • Use .catch(() => false) for visibility checks

Phase 4: Generate Tests

See examples/e2e-tests.md for templates.

Key patterns:

  • Add @visual tag to test title for visual regression tests (e.g., 'should display page correctly @visual')
  • Follow AAA pattern (Arrange, Act, Assert)
  • Create constants for reusable test data
  • All logic in Page Objects (no separate helpers or fixtures)

Test File Structure

__tests__/
├── e2e/
│   ├── pages/           # Page Object classes (ALL locators & interaction logic)
│   │   └── [page-name]-page.ts
│   └── [feature].spec.ts  # Integration tests (include @visual tag for visual checks)
└── constants/           # Test data only (URLs, emails, text values)
    └── test-data.ts

Important Notes:

  • All locators in Page Objects - No separate selectors file, locators are defined as class properties
  • No helpers folder - All interaction methods belong in Page Object classes
  • No fixtures folder - Use standard Playwright test setup
  • No visual folder - Visual tests are integrated with integration tests using @visual tag

Visual Testing Best Practices

ALWAYS Prefer Component-Level Screenshots

Never use full-page screenshots. Component-level screenshots are more stable and focused:

// CORRECT - Component-level screenshot
await expect(featurePage.header).toHaveScreenshot('preview-mode-header.png');
await expect(featurePage.globalStylesPanel).toHaveScreenshot('styles-expanded.png');

// WRONG - Full-page screenshot (too fragile)
await expect(page).toHaveScreenshot('preview-mode.png');

Why Component-Level Screenshots?

Full PageComponent
Fails when ANY element changesOnly fails when the specific component changes
Large image filesSmall, focused images
Hard to diagnose failuresEasy to see what changed
Flaky due to animationsStable, isolated scope

Strict Pixel Comparison

In playwright.config.ts, use strict comparison (no tolerance):

expect: {
  toHaveScreenshot: {
    maxDiffPixels: 0, // Strict - no pixel difference allowed
  },
},

Add Component Locators to Page Objects

// In your Page Object class constructor
this.header = page.locator('.guido__header, header').first();
this.globalStylesPanel = page.getByRole('tabpanel', { name: 'General Styles' });
this.leftSidebar = page.locator('.left-sidebar, [class*="sidebar"]').first();

Screenshot Naming Convention

Use descriptive names that indicate the component and state:

// Good names
await expect(featurePage.header).toHaveScreenshot('header-preview-mode.png');
await expect(featurePage.globalStylesPanel).toHaveScreenshot('styles-mobile-view.png');

// Bad names (too generic)
await expect(element).toHaveScreenshot('test1.png');

API Mocking

For deterministic tests, mock API responses using the mockApi utility:

import { API_ENDPOINTS } from '../enums/constants';
import { mockApi } from '../mockServer';

test('displays empty state @visual', async ({ page }) => {
  // Setup mocks BEFORE navigation
  await mockApi(page, `**/${API_ENDPOINTS.LIST_DATA}**`, 'list-data/empty.json');

  const featurePage = new FeaturePage(page);
  await featurePage.goto('/page');
  await expect(featurePage.emptyState).toHaveScreenshot('empty-state.png');
});

See references/api-mocking.md for full documentation.


Important Notes

  • Always explore first - Use playwright-cli snapshot before writing any code
  • Mock APIs - Use mockApi utility for deterministic test data
  • Test interactions - Verify element refs work before generating Page Objects
  • Visual tests use @visual tag in title - e.g., 'component visual test @visual'
  • Use component-level screenshots - NEVER use full-page screenshots
  • Strict pixel comparison - Use maxDiffPixels: 0 in config
  • Don't separate visual tests - Integrate them with integration tests when needed
  • Follow existing patterns - Match project structure exactly
  • Use descriptive names - Test names should describe expected behavior
  • Keep Page Objects comprehensive - Include wait methods, helper methods, and assertion helpers
  • Never use page.waitForTimeout() - Use proper waitFor conditions instead

Error Handling

ErrorSolution
Element not foundTake new snapshot, verify ref value
Timeout on navigationIncrease timeout or check URL
Screenshot mismatchUpdate baseline with --update-snapshots
Network errorsCheck console messages and network requests

GitHub Actions Workflow

Example CI/CD workflow for E2E tests with sharding and visual regression:

name: E2E Tests

on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review]
  push:
    branches: [develop]
  workflow_dispatch:
    inputs:
      update_snapshots:
        description: 'Update snapshots only'
        required: false
        default: 'false'
        type: boolean

jobs:
  run-e2e-tests:
    if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' || github.event_name == 'push'
    timeout-minutes: 60
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shardIndex: [1, 2, 3, 4]
        shardTotal: [4]
    permissions:
      contents: read
      issues: write
      pull-requests: write
    env:
      APP_URL: https://localhost:3000
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm

      - name: Install dependencies
        run: npm ci

      - name: Install Playwright browsers
        run: npx playwright install --with-deps

      - name: Start dev server
        run: |
          npm run dev &
          npx wait-on ${{ env.APP_URL }}

      - name: Run E2E Tests
        run: |
          if [ "${{ inputs.update_snapshots }}" == "true" ]; then
            npx playwright test --grep @visual --update-snapshots --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter=blob
          else
            npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter=blob
          fi

      - name: Upload blob report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: blob-report-${{ github.run_id }}-${{ matrix.shardIndex }}
          path: blob-report/
          retention-days: 3

  merge-reports:
    if: always()
    needs: [run-e2e-tests]
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm

      - name: Install dependencies
        run: npm ci

      - name: Download blob reports
        uses: actions/download-artifact@v4
        with:
          path: all-blob-reports
          pattern: blob-report-${{ github.run_id }}-*
          merge-multiple: true

      - name: Merge reports
        run: npx playwright merge-reports --reporter html ./all-blob-reports

      - name: Upload HTML report
        uses: actions/upload-artifact@v4
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 7

Key Workflow Features

FeatureDescription
ShardingTests split across 4 parallel runners for speed
Visual updateworkflow_dispatch with update_snapshots input to update baselines
Blob reportsEach shard uploads blob report for later merging
Report mergingCombined HTML report from all shards
grep @visualOnly visual tests updated when update_snapshots is true

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

40.25%
按下载量换算25

Claude

28.33%
按下载量换算18

Cursor

18.64%
按下载量换算12

Gemini CLI

10.12%
按下载量换算6

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills