lost-pixel icon indicating copy to clipboard operation
lost-pixel copied to clipboard

support network request interception

Open redabacha opened this issue 3 years ago • 5 comments

Mode

Storybook

Feature description

would be nice if there was a config option allowing us to setup custom page routes before loading the page https://playwright.dev/docs/network#modify-requests. however, the current storybook solution uses file:// urls when loading pages which are known to be problematic with this, see https://github.com/microsoft/playwright/issues/8412.

redabacha avatar Oct 27 '22 14:10 redabacha

Hey @redabacha! I am myself very keen on the idea that lost-pixel supports something like MSW out of the box so you can just write your handlers and render different pages with different responses! Could you elaborate a little bit more on your use case? I think in Storybook you'd already be able to use MSW to render different stories with different responses. You'd use msw plugin storybook.

Still, I would want to know a bit more about the problem you are trying to solve and see how we can be of help!

d-ivashchuk avatar Oct 31 '22 08:10 d-ivashchuk

hi @d-ivashchuk, msw is great however since it runs in a service worker it doesn't have access to the nodejs environment which is very useful when needing to interact with the local filesystem for example and it also doesn't have a capability of being able to record / replay network requests unlike alternatives such as polly.js (which has a working playwright integration https://netflix.github.io/pollyjs/#/adapters/playwright). being able to record / replay network requests is very helpful on larger apps where the maintenance burden of writing mocks for many requests is quite high.

redabacha avatar Nov 03 '22 11:11 redabacha

Okay, gotcha! So you want to have more access to native playwright integrations when it comes to working with network?

d-ivashchuk avatar Nov 03 '22 11:11 d-ivashchuk

So you want to have more access to native playwright integrations when it comes to working with network?

yes exactly, that would be awesome if that could be supported! :sweat_smile:

redabacha avatar Nov 03 '22 11:11 redabacha

we can definitely look into it! If you will have any idea on specific tools or maybe would want to do a PR to enable this - I'd be more than happy to assist you!

d-ivashchuk avatar Nov 03 '22 21:11 d-ivashchuk