Code Monkey home page Code Monkey logo

Comments (18)

Eptis avatar Eptis commented on May 16, 2024 1

Is this still being considered? For me this is the only reason not to use Mirage because I consume multiple API's on different domains.

from ember-cli-mirage.

samselikoff avatar samselikoff commented on May 16, 2024

looks like it's getting added to pretender! pretenderjs/pretender#66

from ember-cli-mirage.

theazureshadow avatar theazureshadow commented on May 16, 2024

And it has landed in Pretender 0.8.0

from ember-cli-mirage.

acorncom avatar acorncom commented on May 16, 2024

@samselikoff Any pointers on where you'd like to get started on this? I've got a client who needs it, so may be able to help push this in the right direction tomorrow ...

from ember-cli-mirage.

theazureshadow avatar theazureshadow commented on May 16, 2024

@acorncom: You might be able to get it to work without any changes in ember-cli-mirage. In app/mirage/config.js, try setting this.namespace to your API endpoint hostname and path. For us that looks something like:

this.namespace = config.api.host + '/' + config.api.namespace;

from ember-cli-mirage.

acorncom avatar acorncom commented on May 16, 2024

@theazureshadow Sadly, that doesn't work. What I'm trying to do is build a prototype backed by Ember-CLI-Mirage that uses Algolia for searching. I either need a way to mock responses from Algolia for non-acceptance tests (I can do it for acceptance tests) or a way to poke a hole clean through Mirage so I can actually talk to Algolia. Things work smoothly if I turn off Mirage altogether, but then the rest of my prototype doesn't work (no data ;-)

I'm getting this error:

Pretender will not respond to requests for URLs. It is not possible to accurately simluate the browser's CSP. Remove the http://<app-id>-dsn.algolia.net from http://<app-id>-dsn.algolia.net/1/indexes/*/queries

from ember-cli-mirage.

samselikoff avatar samselikoff commented on May 16, 2024

are you sure you updated Pretender? That error message doesn't exist in 0.9.

To poke a hole in Mirage add

this.pretender.get('/*passthrough', this.pretender.passthrough);

to the bottom of your mirage/config.js.

from ember-cli-mirage.

acorncom avatar acorncom commented on May 16, 2024

@samselikoff Yes, sadly, I've tried that exact line of code for poking a hole in Mirage. Actually, more accurately, I've tried the following:

this.pretender.get('/1/index*', this.pretender.passthrough);

within the app/mirage/config function that is exported. And I've tried it with pretender 0.6.0, 0.7.0 and 0.9.0. With 0.9.0 the error I'm getting is:

Mirage: Your Ember app tried to POST 'http://<app-id>-dsn.algolia.net/1/indexes/*/queries', but there was no route defined to handle this request. Define a route that matches this path in your mirage/config.js file.

but it's still approximately the same. I've dug in deep a few times and seem to be getting snagged on the host registry combined with an absolute URL (which Algolia's search client requires).

I've been quietly beating my head against a wall, hoping that the upgrade to pretender would magically fix everything ;-) When it didn't, I thought I'd better ask a few more questions ...

from ember-cli-mirage.

vvo avatar vvo commented on May 16, 2024

@acorncom as for mocking xhrs at Algolia we built https://github.com/algolia/faux-jax maybe have a look

from ember-cli-mirage.

samselikoff avatar samselikoff commented on May 16, 2024

Sorry, sounds v frustrating @acorncom. I should have time to take a look at this soon.

from ember-cli-mirage.

samselikoff avatar samselikoff commented on May 16, 2024

Ah looks like you're POST'ing, try this

this.pretender.get('/1/index*', this.pretender.passthrough);
this.pretender.post('/1/index*', this.pretender.passthrough);
this.pretender.put('/1/index*', this.pretender.passthrough);
this.pretender.delete('/1/index*', this.pretender.passthrough);

or like I said use /*passthrough for the route and put that at the bottom of your config.js to have all non-handled requests pass through.

from ember-cli-mirage.

samselikoff avatar samselikoff commented on May 16, 2024

Looks like you need to be on jQuery 2.x as well

from ember-cli-mirage.

acorncom avatar acorncom commented on May 16, 2024

@samselikoff Appreciate your help on it. We've been using jQuery 1.x, so that may be the issue. I'll be in touch once I've had a chance to test.

Re: frustrating. Time-consuming at the least ;-) I definitely know far more about the internals of Mirage and Pretender than I did before, let's put it that way ;-)

from ember-cli-mirage.

acorncom avatar acorncom commented on May 16, 2024

@samselikoff Looks like upgrading to jQuery 2.x isn't helping on my end. Am I wasting too much of your time here? Should I open a new issue? I'd be happy to post a reproduction repo if you are inclined to help, but don't want to presume ... Thanks!

from ember-cli-mirage.

blimmer avatar blimmer commented on May 16, 2024

@acorncom are you sure that you're depending on pretender 0.9? It looks like we forgot to update this package's blueprint to install pretender 0.9.

from ember-cli-mirage.

blimmer avatar blimmer commented on May 16, 2024

I'm pretty sure this is possible. I created a sample repo with this working. @acorncom if you can post an app where this is reproducible, that would be great.

from ember-cli-mirage.

acorncom avatar acorncom commented on May 16, 2024

@blimmer Appreciate your sample repo. I'll open a separate issue, as this may be a misconfiguration on my part (don't think so though ...)

from ember-cli-mirage.

samselikoff avatar samselikoff commented on May 16, 2024

Passthrough api has landed, if anyone here still needs help please comment.

http://www.ember-cli-mirage.com/docs/v0.1.x/manually-starting-mirage/

Thanks!

from ember-cli-mirage.

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.