Skip to content

Possible to use Chrome dev tools to throttle network request? #804

Answered by kettanaito
cmacdonnacha asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @cmacdonnacha.

As far as I know, there is no way to access the options set in the DevTools panel on runtime, so MSW cannot know what network throttling options you may have selected. It appears that setting network throttle doesn't affect requests handled by the worker.

If I'm not mistaken, @phryneas has been doing an interesting pattern where he enabled the groups of mocks based on the URL query parameter. You may utilize that to mimic network throttling when testing manually while keeping your automated tests intact.

I recommend creating a custom res() function and making it respect the ?delay=N query parameter set in the URL:

// src/mocks/throttledRes.js
import { createResponseCom…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cmacdonnacha
Comment options

Answer selected by cmacdonnacha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants