React Native: server.use does not add request handlers #2042
Labels
bug
Something isn't working
help wanted
Extra attention is needed
needs:triage
Issues that have not been investigated yet.
scope:react-native
Prerequisites
Environment check
msw
versionNode.js version
21.6.2
Reproduction repository
https://github.com/RayOei/MSW-test/tree/main
Reproduction steps
The repo contains a simple RN app (RN v0.73.4) with Detox (v20.18.1) tests which illustrates the expectations.
For details see the README.md in the repo.
Edit: some additional observations have been added regarding handling of intercepted requests. Also the demo app has been tweaked to help show more clearly what the behaviour is
Current behavior
The first test using the global handler passes: request is intercepted and expected response is send & received.
The test which defines the
server.use
fails, however, as the normal handler is executed instead of this particular one.Logging show the intercept log:
Edit:
I noticed that the listHandlers() does show an added
HttpHandler
but it is not used (or skipped)?Before the
----
the predefined set. After the set including the HttpHandler added byserver.use
.Expected behavior
Expected that [Refresh -> should have Use_Movie_fake_4 last => THIS ONE FAILS] test would pass with request intercepted with the
server.use
as defined in the test with the appropriate response. This followed the information provided in https://mswjs.io/docs/best-practices/structuring-handlersThe text was updated successfully, but these errors were encountered: