If you happen to be using https://github.com/trek/ember-testing-httpRespond it is now included with ember app kit https://github.com/stefanpenner/ember-app-kit/pull/382
These helpers are a thing of beauty! Thanks for the work youāve done
When talking sinon and Ember.js combination I recommend you have a look at the sinon/Ember.js runloop note at ember.js - How do I test Ember.run.later with Sinon? - Stack Overflow
@trek I tried to use this just now, but it causes all my other tests to break (Iām including it globally in my testsā¦) so I might have to just go back to using mockjax for now.
I kinda really liked the idea that this library delivers, though: individual request-specific responses is a really cool pattern. Iām also using Ember Data Factory which seems to be so far working pretty wellā¦
But yeah, gotta switch back to using mockjax for the moment as all my other integration-style tests seem to fall apart when Iām using this library. Not sure why.
Sadly a change in 1.4+ broke this and hasnāt been fixed. Not sure if there is an ETA on it. I havenāt been able to muster enough support to convince anyone this was a ābreaking changeā, so it remains unfixed
@trek, any idea which aspects caused the breakage? Iād be happy to help out fixing it up, but I have not been able to figure out which changes are causing the issue.
I really like the fakehr / httpRespond approach.
https://github.com/trek/ember-testing-httpRespond/pull/13 is the Issue on the library itself, related to the change in this PR on Ember: https://github.com/emberjs/ember.js/pull/4347
In the meantime, I also made https://github.com/trek/pretender which does the fake server approach. Itās based on route-recognizer and FakeXMLHttpRequest so I personally think it fits better into the modern JS ecosystem of smaller parts compared to āone library, many coupled partsā pattern of yesteryear.
Yes, the irony of saying that and working on Ember doesnāt escape me.
That looks really nice. One thing Iāve been using (today, actually) is the data object (ie query params on the URL) for mockjaxā¦ because my API responds differently depending on the passed through query paramsā¦
And also, Iāve been using the fact that mockjax allows you to clear individual mockjax setupsā¦ which is incredibly handy in mocking the changing state of data as I click through data-changing URLs (ie click this, change that data, now Ember-Data expects a request to that URL to be with the updated data, etc.) ā hopefully you know what I mean here.
I was wondering if pretender would afford those things? Using mockjax is pretty clunky and Iād way prefer to use your httpRespond library.
Hey @rwjblue thanks very much for mentioning this. Iām using it to great effect
Hey @trek Iām pretty interested in how your original mocking idea might work for cases where there are actually 4 or 5 models that ember data loads when you, say, click a button? Would you just specify all of the responses?
Or would you have a combo of the server mock with the response mock, or the response as an override? I think that would be awesomeā¦ like a hybridā¦ server, but then the response āupdatesā the server. LOL
Hi @mfeckie , I started reading your book today and was initially encouraged to read about @trekās https://github.com/trek/ember-testing-httpRespond in chapter 9. Of course, a little more research made me realise it is currently broken due to changes introduced in Ember 1.4. What are you using in the mean time to fake HTTP requests? Are you using https://github.com/trek/pretender?
Yeah @keithpitty , Iām sad about the breakage too! Messed up my plan in a big way! Anyway, thatās progress I guess.
I am indeed looking at pretender as the replacement, but am still familiarising myself with the API and consider how it will fit into the overall structure of the book.
Iāve been slow on the next update due to a number of significant changes to Ember, Teaspoon and Rails 4.1! Iām catching up and will hopefully be ready to release the next version in the next month or so.
Hey, so if you are running on 1.5, (wheter via upgrade or greenfield) then it should be working now. I think the patch was done a month ago or so. Iām not sure but I kinda remember it being mentioned that it wasnāt the most ideal patch though.
There is a project that I created to help with exactly what you are wanting to do. It creates fixtures from factories for ember data. It supports RESTAdapter/AMAdapter, has test helpers ( that use mockjax ) to make integration (or unit) testing pretty fun and easy. The whole story is here:
https://github.com/danielspaniel/ember-data-factory-guy
Check it out and let me know what you think.
I started out using teddyzeenny/ember-data-factory and ran into issues were my test setups were becoming monstrously large. Then @Kerrick told me about @danielspanielās ember-data-factory-guy and it reduce the test setup bloat and the overall testing run time in about half.
It also has benefits over ember-data-factory, like having sequences baked into the library.