Comments (9)
I have not had to write a pretender passthru for other URLs, so no experience, sorry, perhaps someone else has?
Since this repo is using Pretender and pretender is not performing passthru as expected, it would seem this is more an issue for the PretenderJS library (https://github.com/pretenderjs/pretender#pass-through)
Here is some comments in the MirageJS code that talks about passthru https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L391.
It looks like while calling the passthru the _getFullPath is being applied https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L464, maybe you need to set urlPrefix and namespace to undefined first looking at the fullPath code https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L479
from miragejs.
The only thing i saw was this logline: https://github.com/miragejs/miragejs/blob/master/lib/mock-server/pretender-config.js#L309-L310
But i do see https://github.com/miragejs/miragejs/blob/master/__tests__/external/browser-only/passthrough-test.js#L41 which makes me think maybe i have config error. Unfortunately i have moved to a setup with an express mock server, but will try to go to old version with mirage and see if i can find more intell.
from miragejs.
I can confirm this issue was about the missing namespace :(
Not documented but in the error log :)
Thanks Brian!
from miragejs.
So it lets passthrough the call, but its not actually returning the data using fetch/axios. Which makes the setup unusable when you want to go slowly from a complete mock to a working api application. I guess that should be documented somewhere @cah-brian-gantzler ?
from miragejs.
When a package is using another package, its really hard to determine what should be documented where. Since the passthru is just calling the pretender passthru, then any issues or nuances should really be documented in pretender.
from miragejs.
It is really scary to see that mirage.js is being built over an unmaintained package like pretender.js. And the interesting thing is that pretender.js is quite small, just a few files.
What is the sense is having a behavior that we need to map all request domains to ensure that they do not break? It should be the opposite. Mirage.js should ensure that all requests pass, except for those that we explicitly mock.
We have a use case that our BE is till being architected and we want to start working on UI. But our app is built over a complex infra and many underlying requests are made to different apis / vendors. I have tried it out and could not get it through. Then when I though about the headache in maintaining this while the prototyping phase is done I had to give up.
Is it on the roadmap to abandon pretender.js? If not, I guess that the foundations of this initiative might be on the wrong direction.
from miragejs.
@alioshr there is currently a way to swap out pretender for MSW. It's experimental, though, and I haven't yet tried it out. #1037
from miragejs.
Hi @IanVS . I have opted in using MSW, just in our testing/staging env. Not registering msw in production. It works pretty well, for our needs on this phase.
But I guess that with some tweaks to mimic some real network behavior for rest api calls, I guess that I would prefer a solution to not rely on service workers, as they are very fragile, as they are restricted by browsers on different conditions (anonymous tabs, etc, vendors, etc).
Of course, for prototyping, we could assume that this issue is not the end of the world, but it limits testing the FE features in diversified browsers, etc. The tradeoff is still positive, imho.
from miragejs.
@alioshr thanks for the update. Are you using MSW together with mirage, or on its own? I've hit my own passthrough error in pretender just now, so I might be following in your footsteps.
from miragejs.
Related Issues (20)
- Example using GraphQL and React Native for Testing HOT 2
- How to fix it? my error is: Mirage: Passthrough request for GET /_next/static/development/_devMiddlewareManifest.json
- `timing` setting does not respect `environment: 'test'` without setting `testConfig` HOT 2
- Seeding doesn't load factories HOT 1
- `Response` object is using deprecated `@ember/error` HOT 1
- Can some updates be made so all config elements can be modularized in all environments including development?
- Issues running inside a webpack based NX monorepo React app HOT 3
- `Serializer.normalize()` not called if request body is `FormData`
- How do you include relationships when mixing the JSON API and Rest serializers? HOT 3
- Has anyone managed to get mirage to work with Next.js 13.4? HOT 8
- Argument of type '{ name: string; role: string[]; }' is not assignable to parameter of type 'Partial<ModelInitializ HOT 1
- Change default request handling HOT 1
- Allow timing to be boolean, default to 'false' due to Pretender handling HOT 6
- Doesn't work with vue3 + fetch + passthrough HOT 2
- Next-pwa throws Failed to execute 'put' on 'Cache': parameter 2 is not of type 'Response' with simple Miraje configuration
- Mirage.js Endpoints Not Found After Navigating and Reloading in Lazy-Loaded Angular App HOT 1
- New Docs Proposal HOT 3
- Firebase `onSnapshot` intercepted
- Composable/extendable traits
- Miragejs not allowing base64 image having lengthy URL
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miragejs.