Skip to content

The correct way to test custom resolver #1253

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

You must be logged in to vote

Hi, @evgenoir. That's a perfect question, thanks for raising this.

Overall, your testing direction is solid. I will try adding a few points below.

Request vs MockedRequest

I like that you construct a plain Request instance to pass as the req argument. But, strictly speaking, the req we construct in MSW is not a 1-1 equivalent of the fetch's Request, as the library's one has extra properties (like passthrough() or params). You may run into some issues as you're passing in not what MSW would produce on its own.

We currently don't expose the means to construct a MockedRequest instance publicly as we treat that instance as an implementation detail of the library. For testing purposes internal…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@evgenoir
Comment options

@kettanaito
Comment options

Answer selected by evgenoir
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