Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/remote server #2041

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

chrisb2244
Copy link

Much cleaner PR for the remote-server handling.

The commits here are not as accurate a reflection of the manner in which they were implemented, and the "initial state" commit may not reflect exactly truthfully the initial state of the msw/feat/ws-sync-handlers branch, from which this code was based.

However, the changed files and number of commits prevents the massive PR in #2028

Only one of these two should be merged (if approved/at all), but this may be easier to review (the final point is almost identical, the other has removed an originally existing console.log line whereas here it is retained).

@chrisb2244
Copy link
Author

In some testing I'm doing (using this branch) I see from the 'initial state' commit 08010c9 log lines like

[msw] RemoteRequestHandler GET https://jsonplaceholder.typicode.com/posts/1 2024-02-19T09:42:58.790Z
[msw] regular request, continue...
[msw] emitting "request" ws event

which is fine when handled, but more confusing when followed by the unhandled message e.g.

[MSW] Warning: intercepted a request without a matching request handler:

  • GET https://jsonplaceholder.typicode.com/posts/1

If you still wish to intercept this unhandled request, please create a request handler for it.
Read more: https://mswjs.io/docs/getting-started/mocks

This is however intended if the remote is attached and then does not handle the request.

I guess in this context, that the first lines are intended only for debugging whilst developing (MSW, not user code)?
Shall I remove them?

I separately receive (in the testing side, from commit 3ea224f)

[msw] RemoteServerHandling: Ignored  GET https://jsonplaceholder.typicode.com/posts/1

or

[msw] RemoteServerHandling: Handled  GET https://jsonplaceholder.typicode.com/posts/1

in setupRemoteServer.ts: line 101, which perhaps serves a similar purpose (if you like those lines, I'll remove the trailing space which gives a double space between 'Ignored'/'Handled' and 'GET').

@chrisb2244 chrisb2244 mentioned this pull request Feb 21, 2024
15 tasks
@marval2
Copy link

marval2 commented Mar 6, 2024

Awesome PR, hope this gets merged. This unlocks overriding server mocks in frameworks like nextjs and remix

@chrisb2244
Copy link
Author

@marval2 - I agree, but just to check, did you try this branch on some code and did it work for you? (I'd be good to know that it works for someone else too in practice, not just that you like the idea, although I'm pleased even if it's only the latter).

@kettanaito
Copy link
Member

Thank you for your work on this! This needs a really thorough review. I don't have the time right now to dive into this. Others are also welcome to review the code and share their thoughts.

@chrisb2244
Copy link
Author

In the spirit of your X posts regarding opening PRs and your comment on Discord with a mid-April timeline, how's this looking? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants