본문으로 건너뛰기
cccskills
무료GitHub에 공개

e2e

Guide for Playwright end-to-end tests. Use to create a new e2e test, debug a flaky test, or test API endpoints. Covers patterns, workarounds, and project conventions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구GitLabPlaywright
설치 방법 보기

포함된 파일(1)

  • SKILL.md5.4 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Playwright E2E Testing Guide

Persona

Read .claude/roles/code-reviewer.md — adopt this profile and follow all its rules.

Activation

This skill activates for:

  • Creating a new e2e test
  • Debugging a flaky test
  • Testing a critical feature (complete API workflow)

Architecture

src/tests/e2e/
├── fixtures/
│   └── test-data.ts          # Test data (webhooks, payloads, etc.)
├── specs/
│   ├── setup.ts              # Server setup (run once)
│   └── <context>/
│       └── <feature>.spec.ts # Tests per feature
└── utils/
    └── test-helpers.ts       # Helpers (API calls, server setup)

Commands

CommandUsage
yarn e2eRun all tests
yarn e2e:debugDebug mode with inspector
yarn test:e2e:reportView HTML report

Workflow: Create a New Test

1. Identify the Context

specs/
├── setup.ts                # Setup (do not touch)
├── webhook/                # Webhook endpoint tests
├── review/                 # Review workflow tests
└── health/                 # Health check tests

2. Write the Test

// specs/webhook/github-webhook.spec.ts
import { test, expect } from "@playwright/test";

test.describe("GitHub Webhook", () => {
  test("should accept a valid pull request event", async ({ request }) => {
    const response = await request.post("/webhooks/github", {
      headers: {
        "content-type": "application/json",
        "x-github-event": "pull_request",
        "x-hub-signature-256": "sha256=valid-signature",
      },
      data: {
        action: "opened",
        pull_request: {
          number: 42,
          title: "feat: add new feature",
          head: { ref: "feat/new-feature" },
          base: { ref: "main" },
        },
        repository: { full_name: "org/repo" },
        sender: { login: "developer" },
      },
    });

    expect(response.status()).toBe(200);
  });

  test("should reject an invalid payload", async ({ request }) => {
    const response = await request.post("/webhooks/github", {
      data: {},
    });

    expect(response.status()).toBe(400);
  });
});

3. Run and Validate

# Debug mode
yarn e2e:debug

# Run a single file
yarn e2e specs/webhook/github-webhook.spec.ts

Selectors (priority for UI tests)

PriorityTypeExample
1data-testid[data-testid="submit-btn"]
2Role (accessibility)getByRole("button", { name: "Submit" })
3TextgetByText("Submit")
4CSS (last resort)table tbody tr

Authentication for API Tests

Token-based Authentication

test.describe("Authenticated API", () => {
  test("should return review status with valid token", async ({ request }) => {
    const response = await request.get("/api/reviews/123", {
      headers: {
        Authorization: `Bearer ${process.env.TEST_API_TOKEN}`,
      },
    });

    expect(response.status()).toBe(200);
    const body = await response.json();
    expect(body).toHaveProperty("status");
  });
});

Fixtures and Test Data

Use existing fixtures

import { TEST_WEBHOOKS, TEST_PAYLOADS } from "../fixtures/test-data";

test("should process a GitLab merge request event", async ({ request }) => {
  const response = await request.post("/webhooks/gitlab", {
    data: TEST_PAYLOADS.gitlabMergeRequest,
  });

  expect(response.status()).toBe(200);
});

Add test data

// fixtures/test-data.ts
export const TEST_PAYLOADS = {
  gitlabMergeRequest: {
    object_kind: "merge_request",
    object_attributes: {
      iid: 1,
      title: "feat: add review automation",
      action: "open",
    },
  },
  githubPullRequest: {
    action: "opened",
    pull_request: {
      number: 42,
      title: "fix: resolve webhook validation",
    },
  },
};

Debugging Flaky Tests

1. Debug mode

yarn e2e:debug specs/webhook/my-test.spec.ts

2. Trace on failure

Traces are enabled on the first retry. After a failure:

yarn test:e2e:report

3. Logs

// Add checkpoints
console.log("Step: Sending webhook payload");

4. Stabilization Patterns

// Flaky: not waiting for server readiness
await request.post("/webhooks/github", { data: payload });

// Stable: verify server is ready first
const health = await request.get("/health");
expect(health.status()).toBe(200);
await request.post("/webhooks/github", { data: payload });

New Test Checklist

  • Test data uses fixtures (not hardcoded)
  • Assertions use expect() from Playwright
  • Test runs in isolation (no dependency on other tests)
  • API responses are properly validated (status + body)
  • Error cases are covered (invalid payloads, missing auth)

Anti-patterns

AvoidPrefer
Hardcoded test dataFixtures from test-data.ts
Tests dependent on each otherIsolated tests
Missing error case coverageTest both success and failure paths
Ignoring response bodyValidate status AND body structure
Arbitrary waitForTimeoutProper readiness checks

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for creating optimized Claude Code agents. Use to design a new specialized agent, a swarm sub-agent, or a multi-agent workflow. Follows the Skill → Agent (preloaded skills) → Skill orchestration pattern.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DGouron/review-flow442026년 10월 18일 업데이트

Anti-overengineering guide based on YAGNI. Use before adding an architectural pattern, during code review, or to challenge an overly complex implementation.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DGouron/review-flow442026년 10월 18일 업데이트

Clean Architecture (Uncle Bob) guide for this project. Use when creating modules, entities, use cases, presenters, controllers, gateways, guards, services. Contains tactical patterns and structure conventions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DGouron/review-flow442026년 10월 18일 업데이트

Audit documentation for duplication, staleness, language issues, and verbosity. Read-only — produces an actionable report.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DGouron/review-flow442026년 10월 18일 업데이트

Local auto-review of modified code (no GitLab/GitHub). Runs 5 sequential audits and generates a local report. Ideal for validating code before creating a MR/PR.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DGouron/review-flow442026년 10월 18일 업데이트

Clean Code (Robert C. Martin) guide to produce and challenge code that is readable, durable, simple, and consistent. Covers naming, functions, comments, smells, and refactor heuristics. Complements `/solid` (SOLID principles) and `/anti-overengineering` (YAGNI/KISS). Activate during the REFACTOR phase of the TDD cycle and during implementation self-review.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DGouron/review-flow442026년 10월 18일 업데이트

DGouron의 스킬 모두 보기

이 스킬의 문제 신고