Skip to content

[Feature] Allow regex URL matching in HAR #27430

Open
@dougouk

Description

Currently the HAR replay matches URL and HTTP method strictly according to the docs.

This prevents me from easily replacing my existing network mocks with HAR mocks

Here is what I mean

Let's say I have an API api/v1/fruits that takes in a query parameter color

The following mocks the API so that the response is mocked for all calls, regardless of what the query parameter is

await page.route('*/**/api/v1/fruits**', async route => {

I would like to use HAR to do the same, but I cannot without manually editing the JSON file.

HAR will create a JSON file for each URL. Meaning if the test runs with api/v1/fruits?color=red then it will create the mock for only the query parameter color=red, and not color=yellow or color=green.

Currently I need to go into the JSON file, copy-paste the existing URL responses, and replace the query parameters. All manually :(


Ideally if there was a configuration to allow URL pattern matching instead of strict, that would help my use case a lot.

Could we have this as a feature please?

Metadata

Assignees

No one assigned

    Labels

    open-to-a-pull-requestThe feature request looks good, we are open to reviewing a PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions