Skip to content

[Feature]: Better API for handling request interceptors #34253

Open
@andreaslarssen

Description

@andreaslarssen

🚀 Feature Request

I'm new to Playwright, coming from Cypress, so I might have missed something here.
It seems to me that when intercepting API requests with the page.route() method, you're not able to specify which http method to intercept?
If it's not possible, I would very much like to see that implemented

Example

I was expecting to see something like:

  await page.route('POST', 'my/route', (route) => {
      route.fulfill(
        { json },
      );
    });

Motivation

It would make it possible to write cleaner code.
Am I missing something here? How are we supposed to mock two different request to same URL with different http method

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions