Skip to content

feat: Add new route interceptor features - #15

Merged
foxable merged 3 commits into
cronn:mainfrom
florian-cronn:feature/route-interceptors
Sep 2, 2026
Merged

feat: Add new route interceptor features#15
foxable merged 3 commits into
cronn:mainfrom
florian-cronn:feature/route-interceptors

Conversation

@florian-cronn

@florian-cronn florian-cronn commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Adds a new API which can be used to intercept network requests in playwright using the page.route functionality.

The utilities introduced by this pull request add methods which scope route interceptors for the duration of a callback, to allow temporary and focused request manipulation.

Example:

await interceptRoute(page, pathPattern("/api/users/1"))
  .respondWith({ status: 404 })
  .during(async () => {
    await page.goto("/users/1/profile");
    await expect(page.getByRole("heading", { level: 1 })).toHaveText(
      "Unknown user",
    );
  });

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 83d03e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cronn/playwright-utils Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@florian-cronn
florian-cronn force-pushed the feature/route-interceptors branch from f1289ea to 859bbaa Compare September 2, 2026 09:34
@florian-cronn
florian-cronn force-pushed the feature/route-interceptors branch from 859bbaa to 99aa363 Compare September 2, 2026 09:35
Comment thread src/api/route-interceptor/interceptor.ts
Comment thread src/api/route-interceptor/index.ts Outdated
Comment thread src/api/route-interceptor/index.ts Outdated
Comment thread src/api/route-interceptor/index.ts Outdated
Comment thread src/api/route-interceptor/index.ts Outdated
Comment thread tests/route-interceptor.spec.ts Outdated
Comment thread tests/route-interceptor.spec.ts Outdated
Comment thread docs/src/api/route-interceptor.md Outdated
Comment thread docs/src/api/route-interceptor.md Outdated
@florian-cronn
florian-cronn force-pushed the feature/route-interceptors branch from 570b217 to 7c7614e Compare September 2, 2026 13:32
@foxable
foxable merged commit 4bc4055 into cronn:main Sep 2, 2026
2 checks passed
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.

2 participants