Unify the setup and usage of msw in stories #34450
Labels
developer-experience
Addressing these issues will improve the experience of developers working on Teleport
ui
Currently, we use msw both from
window.msw
(example) and by importing it from the msw package (example).The version from the window seems to work only over local IP. If
ctx.delay
is used in the msw handlers, it seems to have no effect – the responses are returned immediately.The version from the msw package works only over localhost. It requires a different setup which is currently done per story, but according to the docs it should be done globally in
preview.js
.ctx.delay
seems to work with this version with no problems.This causes problems when viewing stories because some work only in localhost and some work only over local IP.
I haven't tried to understand the use case behind the window version of msw, but since
ctx.delay
doesn't seem to work with it, I believe we should migrate to the second approach. Perhaps it's possible to make it support both the local IP and localhost, so that no matter how someone launches the storyybook, the stories will work.The text was updated successfully, but these errors were encountered: