So, my current Ember project is built using Ember App Kit. My tests are using the wonderful httpRespond to mock out ajax requests.
However, I have started to notice that while httpRespond is great, you really only test how your app responds to responses from the API and not so much how your app responds to interactions from the user. An example of this I guess is submitting a form with server side field validations.
With httpRespond you mock out the response, which will be returned regardless of what the request looked like. So, I can essentially click the submit button on my form and successfully submit the form without having filled in any fields. This feels like we're missing something.
Enter Trek's Pretender. This is a bit like a sup'ed up version of httpRespond. It looks a little like a mock server but is just mocking out the xhr like httpRespond. Except you get access to the request which you can inspect before deciding what response to return.
I like this idea a lot and I want to use it. However....
Pretender is not yet Ember Testing aware. httpRepond understands the async workings of Ember and will wait for async events in Ember to finish before carrying on in the test. Pretender however, does not do this yet.
For instance, if I click a link in my Ember app which kicks off a few different async events, my test will not wait for these async events to finish before continuing and therefore, the test finishes executing before the async events have finished.
Which brings me to my question...
How do we go about making Pretender Ember Testing aware?
Trek has mentioned that this is something he has yet to do, but I'm not sure when he might have time to get to it. So I'd love to get it going if possible.
Does anyone have any thoughts how we might about attempting this?
I'm having a lot of success with ember-cli-mirage. It sits on top of pretender and allows you to create both fixtures for development and factories for use in tests. If you're still having trouble with this, or for anyone else, this is a really easy way to get control over your apps development data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With