Coder Social home page Coder Social logo

Comments (9)

cah-brian-gantzler avatar cah-brian-gantzler commented on June 7, 2024

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.

maapteh avatar maapteh commented on June 7, 2024

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.

maapteh avatar maapteh commented on June 7, 2024

I can confirm this issue was about the missing namespace :(
Not documented but in the error log :)

Thanks Brian!

from miragejs.

maapteh avatar maapteh commented on June 7, 2024

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.

cah-brian-gantzler avatar cah-brian-gantzler commented on June 7, 2024

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.

alioshr avatar alioshr commented on June 7, 2024

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.

IanVS avatar IanVS commented on June 7, 2024

@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.

alioshr avatar alioshr commented on June 7, 2024

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.

IanVS avatar IanVS commented on June 7, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.