-
Notifications
You must be signed in to change notification settings - Fork 22
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
How to mock server so that feathers-pinia behaves normally with mocked responses and delays ? #140
Comments
We also found this possible way: |
@barnacker, could you share the code that you used to set this up? I'd like to give it its own section in the "Common Patterns" page. I would really appreciate it. |
Yes! Roughly to make it easier we created this class (see at the bottom) so we can register mocked services with mocked data and we integrated it into our feathers-client.ts like below. Then you can create the pinia store as usual and it will react as usual, we managed to override the authentication service too so its greate for fast login :) Here below is our fancier latest code, it's designed to avoid multipicating listeners ( server.on('create',... ) on the socket server... but if you prefer a funcionning dirtyier simpler exemple here is one you can also use:
mockFeathersService.ts Class
Example mocked data and create function
|
I hope this inspires you, our next goal I think is to allow for hybrid project with real and mocked services accessible during development :) |
Hi! I want to mock a feathers socket server. I was thiking of doing it on the feathers-client / socket.io transport declarations maybe and completely skip network and sockets but yet getting responses as if a real feathers servers replied.
It's really important that I do not use a real server and real neworking for my UI Prototype / POC, all is to be mocked even delays of responses etc...
I tried mock-socket and replaced the socket.io import in the feathers-client file... I can intercept the create signal for example and I see Pinia is pending for creation but no matter what I tried I emit back, feathers-pinia doesnt see it ... I might just not reply propely.
Any ideas?
Here is what we did... it almost works!!! :-|
Code on the UI:
Example feathers-client.ts file:
The text was updated successfully, but these errors were encountered: