Replies: 2 comments 6 replies
-
Hi, @nzakas! Thank you so much for putting your time to provide the feedback. I will try to process it and write down some action points I can take to improve the docs. Do you mind elaborating on a few moments?
Did you feel like you had to choose between these? This may be a poor visual representation because those two are basically a list, and you need to read them in order: first, you lean how to intercept requests; second, you learn how to return mocked responses. I think this separation makes sense. You can intercept requests without mocking the responses—that a legitimate use case.
Yeah, I see. What you saying is completely valid. From what I can see, the biggest frustration on your end was due to the lack of a complete A-Z example to follow. The Getting started docs themselves are modular. MSW can and is used for many many things, and it'd mean writing 10 getting started guides based on what you personally want to use it. So I made a decision to split it into sections and the intention here is that you open the Getting started page and then go through the steps, read the references pages, then go back and continue the tutorial. You don't see immediate usage examples of the I need to think what's the best way to address this.
Yeah, I think the docs fail you at the very beginning. You expect each step in the Getting started tutorial to be a complete example but it's not by design. You follow a journey:
Now, these steps are dependent on each other so you progress through them in order. If you jump to the Integration parts, they won't be talking about how to describe the network because (a) it's not their concern; (b) the network description is the same anywhere you decide to integrate it.
This is a fantastic feedback. I think that page should at least reference to where the
What would be the simple getting started example for you? This is that tricky part I was talking about. People use MSW in all sorts of way with all sorts of tools. It being environment- and framework-agnostic makes it difficult to create that "simple" example because that "simple" is different for everyone coming to the library. Having such example also creates a confusing precedent of being "the" example. Then a bunch of folks follow it and make the wrong conclusions, like "Oh, this works only in React" or "Shoot, that seems to be for Jest only", etc. Folks are usually integrating MSW with other tools (Cypress/Playwright/Jest). And even that is not mandatory, the library will work in a simple Can you please tell me more about where you are integrating MSW? Really want to learn from your expectations.
I interpret "complete" here as "comprehensive". If that's the case, each example repo in the JavaScript frameworks section of the examples is comprehensive. It features MSW integrations for development and integration + E2E levels of testing at the same time. Those are the most complete examples to me.
The value of those examples is not so much to show you how MSW works but to highlight where different frameworks keep their integration points. MSW works the same everywhere, but the frameworks require you to know where to put those integrations. For example, Remix has I do believe what caused the most frustration for you was thinking that MSW can be used in one particular way, like most tools are. You pull in MSW is a bit unique in that regard, and I agree it can get unclear what/how you do with it. I value your feedback a lot, and I think I need to improve the docs. Just have those few questions above to help me narrow down the exact improvements. It gets even more complex as we bring in support for more protocols, like WebSocket. Now, mocking WebSockets is completely different from mocking HTTP, but there are reused experiences also, like the integration points remain the same. It's not easy to get this right. Hope to iterate on this with you and make the docs better. Once again, thank you! |
Beta Was this translation helpful? Give feedback.
-
UpdateI've rewritten the Getting started tutorial based on your feedback, @nzakas! I hope it's in a much better shape now. Please let me know what you think about it now. |
Beta Was this translation helpful? Give feedback.
-
I just recently started using MSW, and I found the documentation to be difficult to follow. I have some suggestions on how to improve things:
Getting Started
I wanted to set up a fake server for testing a Node.js project. I was surprised that I couldn't find a complete example anywhere on the site. To understand better, this is what I did my first time trying to use MSW:
http.get
(for example) at the top level or are exporting ahandlers
variable. Both don't make sense without the context of how they're used, which I still have not encountered. I don't know what to do with any of this information. So I go over to "Mocking responses"....handlers
and where are they defined? Where are the interceptors? Where do they go in the server? Lost, I go back to Getting Started and click on "Usage Examples"At this point, I have not found a single complete example in one place. It took me another couple of days before I finally figured out how to piece all of the disparate docs together to get something working.
Now, there is a lot of good information in the docs, but it all seems focused primarily on explaining each individual piece of MSW rather than giving a good understanding of how all the pieces work together.
Suggestions
Mocking responses
The Mocking responses page is missing a common use case: Returning a non-200 code with a JSON body. The
text()
andjson()
are nice, but they hide a lot of what has to happen to a JSON body to work properly in error conditions.Beta Was this translation helpful? Give feedback.
All reactions