Skip to content

Add request-mocking example with page.route() patterns#4

Open
kevinvalentinopanjaitan wants to merge 1 commit intocheckly:mainfrom
kevinvalentinopanjaitan:feat/request-mocking
Open

Add request-mocking example with page.route() patterns#4
kevinvalentinopanjaitan wants to merge 1 commit intocheckly:mainfrom
kevinvalentinopanjaitan:feat/request-mocking

Conversation

@kevinvalentinopanjaitan
Copy link

Summary

  • Adds a new request-mocking/ example demonstrating Playwright's page.route() API
  • Covers three core interception patterns across 9 self-contained tests:
    • route.fulfill() — return synthetic responses (mock JSON, simulate errors, glob patterns)
    • route.abort() — block requests (analytics calls, images, unavailable services)
    • Request inspection + waitForRequest / waitForResponse

Test plan

  • cd request-mocking && npm install
  • npx playwright test — all 9 tests pass
  • No external server required — all tests use page.setContent() with inline HTML

Demonstrates the three core Playwright request interception APIs:
- route.fulfill() — return synthetic responses without hitting a real server
- route.abort() — block requests (analytics, images, unavailable services)
- route.continue() inspection, waitForRequest, and waitForResponse

All 9 tests are self-contained using page.setContent() with absolute URLs
so Playwright can intercept them without a running web server.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant