Rayrun
← Back to Discord Forum

Modifying network requests and saving to HAR

I am setting up our testing on Playwright. The idea is to only test behaviour of the front-end with given HTTP responses, so I'm saving HTTP requests to a HAR file on first run and then routing everything from a file on successive test runs.

I read from documentation (https://playwright.dev/docs/mock#replaying-from-har) that

HAR replay matches URL and HTTP method strictly. For POST requests, it also matches POST payloads strictly. If multiple recordings match a request, the one with the most matching headers is picked.

So I want to make sure that calls to the same resource (i.e. get collection) are matched to the correct responses (for example if one is done before and one after making a modification to a resource.

My thought was to append a unique header to each request.

But looking at the resulting HAR file, the new header is not added to any requests. What am I doing wrong? Here's the full code to the fixture I'm using:

This thread is trying to answer question "Why is the new header not added to any requests in the resulting HAR file when testing on Playwright?"

1 reply

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.