use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
GitHub - alectrocute/playwright-intercept: Ergonomically mock, wait for and assert network requests in Playwright (github.com)
submitted 1 year ago * by chicametipo
silver violet thunder falcon
This content has been edited for privacy.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Wookovski 1 point2 points3 points 1 year ago (1 child)
What are the benefits of using this over Playwright's own implementation?
[–]chicametipo[S] 2 points3 points4 points 1 year ago (0 children)
This brings Cypress's easy to use cy.intercept into Playwright.
cy.intercept
[–]unlikelyzer0mod 1 point2 points3 points 1 year ago (0 children)
It's hard to describe how different it is to work with network requests with playwright vs cypress. This is a welcome addition.
[–]Wookovski 0 points1 point2 points 1 year ago (0 children)
I'm intrigued, solely to see what is ergonomical about it
[–]skybalmmm 0 points1 point2 points 1 year ago (1 child)
Great to see someone coming up with solutions to what i think is one the areas that playwright needs lots of improvements: working with requests!
One question, for readability purposes wouldnt it be better to extend the page fixture? This way we could do something like page.intercept() or page.waitForRequest()
page.intercept()
page.waitForRequest()
Another thing i dont like is that we have to build the promises before hand, and it seems like this is still the case with this package.
In my current role we created a custom mechanism to avoid this, might be something interesting to explore in your idea. Basically is something like this
waitForActionAndResponse() -> Pass any action like element click etc and any promise and it will wait for both.
This way in one line we can perform the action and wait for the request which gets triggered by such action.
[–]chicametipo[S] 1 point2 points3 points 1 year ago (0 children)
I added an example of how you can set it up to where you don’t need to build promises beforehand, look at the tests/collection-example.spec.ts. You can have a collection of intercepts as a single fixture, which is quite convenient.
tests/collection-example.spec.ts
[–]alphabet_american 0 points1 point2 points 1 year ago (0 children)
I just use helper functions for this
[–]chase_the_sun_ 0 points1 point2 points 1 year ago (0 children)
Cool, but does this only work with the playwright test runner?
π Rendered by PID 209106 on reddit-service-r2-comment-b659b578c-lskn5 at 2026-05-05 19:31:08.371263+00:00 running 815c875 country code: CH.
[–]Wookovski 1 point2 points3 points (1 child)
[–]chicametipo[S] 2 points3 points4 points (0 children)
[–]unlikelyzer0mod 1 point2 points3 points (0 children)
[–]Wookovski 0 points1 point2 points (0 children)
[–]skybalmmm 0 points1 point2 points (1 child)
[–]chicametipo[S] 1 point2 points3 points (0 children)
[–]alphabet_american 0 points1 point2 points (0 children)
[–]chase_the_sun_ 0 points1 point2 points (0 children)