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

playwright-network-mocking

Playwright workflows for deterministic third-party responses using page.route().

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

연동 도구Playwright
설치 방법 보기

포함된 파일(1)

  • SKILL.md2.4 KB

SKILL.md(원문)

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

Playwright Network Mocking

Overview

Use this skill when a test depends on a slow, unreliable, or external service and you need deterministic responses without hitting the real provider. It lets you isolate the boundary that matters while keeping the rest of the application real.

Do not use this skill when the real third-party integration is the feature under test, or when the app is already local and deterministic without request interception.

When to Use

  • When a test depends on an unreliable or slow external API.
  • When you need deterministic responses for billing, email, auth, analytics, or similar services.
  • When you want to mock the minimum necessary surface area and leave the rest of the app untouched.

When Not to Use

  • When the test must validate a real provider integration end to end.
  • When the login UI is the feature under test.
  • When you are diagnosing a flaky test and should start with playwright-debugging instead.

Network Interception

Use page.route() to replace external responses with deterministic data before the page makes the request.

import { test, expect } from '@playwright/test';

test('shows premium dashboard when billing is active', async ({ page }) => {
  await page.route('**/api/v1/billing/status', async route => {
    await route.fulfill({
      status: 200,
      json: {
        subscription: 'active',
        plan: 'premium',
      },
    });
  });

  await page.goto('/dashboard');

  await expect(page.getByRole('heading', { name: 'Welcome to Premium' })).toBeVisible();
});

Intercept only the unstable boundary and leave the rest of the application real. If the code under test makes several external calls, mock the minimum necessary surface area.

Prefer page.route() when the response is part of the behavior under test and must be controlled from the browser context. If you need broader, suite-wide control, consider a fixture or a backend test double instead of scattering route handlers through individual tests.

Verification

Verify the intercepted request produces the expected UI and that the real service is not required for the test to pass.

Typical checks:

npx playwright test tests/dashboard.spec.ts

Use trace viewer or UI mode to confirm the mocked response is the one the app consumed.

리뷰

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

댓글

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

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

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

0 / 1,000자

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

같은 저장소의 스킬

Playwright workflows for authenticated browser state reuse through storageState and setup projects.

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

hzijad/playwright-agent-skills92026년 7월 16일 업데이트

Conducts rigorous authoring and review of Playwright E2E tests. Enforces accessibility-first locators, web-first assertions, strict isolation, and DAMP architecture. Use when generating, refactoring, or reviewing any Playwright test code.

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

hzijad/playwright-agent-skills92026년 7월 16일 업데이트

Diagnostic Playwright workflows for flaky or failing tests, including trace analysis, UI mode, and state isolation.

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

hzijad/playwright-agent-skills92026년 7월 16일 업데이트

hzijad의 스킬 모두 보기

이 스킬의 문제 신고