Skip to content

feat(route-interceptor): Add RouteInterceptor#waitForResponse/Request - #18

Merged
foxable merged 1 commit into
cronn:mainfrom
florian-cronn:feature/response-capturing
Sep 3, 2026
Merged

feat(route-interceptor): Add RouteInterceptor#waitForResponse/Request#18
foxable merged 1 commit into
cronn:mainfrom
florian-cronn:feature/response-capturing

Conversation

@florian-cronn

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

Copy link
Copy Markdown
Contributor

Adds listeners for request/response using the same route-interceptor interface:

const interceptor = interceptRoute(page, matchPath("/api/users/1"));

await interceptor.respondWith({ status: 500 }).during(async () => {
  const responsePromise = interceptor.waitForResponse();
  await page.getByRole("button", { name: "Fetch user" }).click();
  const response = await responsePromise;

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

Sometimes a test needs to wait until the server response was received before continuing.

@changeset-bot

changeset-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5293730

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/response-capturing branch 3 times, most recently from d7f6b66 to 11c0964 Compare September 3, 2026 11:53
@foxable
foxable self-requested a review September 3, 2026 12:01
@florian-cronn
florian-cronn force-pushed the feature/response-capturing branch from 11c0964 to 1430804 Compare September 3, 2026 12:04
Comment thread tests/route-interceptor.spec.ts Outdated
Comment thread tests/route-interceptor.spec.ts Outdated
@florian-cronn
florian-cronn force-pushed the feature/response-capturing branch from 1430804 to 52bbd84 Compare September 3, 2026 12:14
@florian-cronn
florian-cronn force-pushed the feature/response-capturing branch from 52bbd84 to 5293730 Compare September 3, 2026 12:15
@foxable
foxable merged commit f7c4e82 into cronn:main Sep 3, 2026
2 checks passed
@florian-cronn
florian-cronn deleted the feature/response-capturing branch September 3, 2026 12:38
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