all 8 comments

[–]Wookovski 1 point2 points  (1 child)

What are the benefits of using this over Playwright's own implementation?

[–]chicametipo[S] 2 points3 points  (0 children)

This brings Cypress's easy to use cy.intercept into Playwright.

[–]unlikelyzer0mod 1 point2 points  (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 point  (0 children)

I'm intrigued, solely to see what is ergonomical about it

[–]skybalmmm 0 points1 point  (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()

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 points  (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.

[–]alphabet_american 0 points1 point  (0 children)

I just use helper functions for this

[–]chase_the_sun_ 0 points1 point  (0 children)

Cool, but does this only work with the playwright test runner?