Intermittent Failures Testing Ember App #821

Closed
joefiorini opened this Issue Mar 19, 2013 · 8 comments

Comments

Projects
None yet
4 participants

I'm having trouble testing my Ember app that uses ember-data to request data.

The only thing slightly unusual that I'm doing is using sinon.js to fake out the Ajax request. Since I can control the response, this allows me to test without model callbacks.

Here are my testing files:

When I run my tests, I'm letting the entire Ember app load into QUnit's fixture. I control the router in my test by transitioning to the state I want to test before running the first test. In between each test I use App.reset() to clear the state of the previous test and reload the route.

The problem is that the second test that runs tries to look up the adapter on the wrong store. When I debug I can see the App.store.toString() returns (for example) "<(subclass of DS.Store):ember747>" but when it get into the store's preprocessData callback, this.toString() returns "<(subclass of DS.Store):ember621>"?

I'm getting quite frustrated by this, and I'm not sure what to look at next. @trek, any ideas what might be going on here?

Thanks!

Alright, I think I figured it out. In my setup callback I was assigning the DS.Store after doing an App.reset(). It looks like App.reset() actually triggers the router, causing my route handler to run and look up a DS.Store before the one I created was assigned in the test. Therefore, loading the model used the anonymous store instead of the explicit one. Moving the DS.Store creation before the App.reset() fixed it (surprisingly, since App.reset actually destroys the container?) @wycats @wagenet does this sound right?

Thanks!

Contributor

CodeOfficer commented Mar 19, 2013

@joefiorini App.reset() actually destroys the app container and calls initialize on the app again which then runs the app injections. Ember Data defines an app injection which will create the default store. So, you should not need to reset the store manually.

https://github.com/emberjs/ember.js/blob/master/packages/ember-application/lib/system/application.js#L433
https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/application_ext.js#L68

Except I do not want to use the default store; I have a custom adapter that I need because I'm loading denormalized data.

Closing this as my intermittent failures are fixed now. Unfortunatley, there were too many issues to nail it down to a specific cause I can note here.

@joefiorini joefiorini closed this Apr 3, 2013

Owner

stefanpenner commented Apr 3, 2013

@joefiorini I would like to see the issues you are having, would you be up to touch base thursday evening, or sometime this weekend?

@stefanpenner That would be lovely. I'm past the problems that cause me to open this issue, but I after upgrading to RC2 I got a host of test failures, mostly tying back to em-data. Although I might have it all back by Thursday, I'd love to talk anyway just to see if I'm doing anything crazy and better understand how other people are testing Ember. Up for that? 9pm EST work for you?

If you wanna do testing in ember with rails, check out my new
ember-konacha-rails gem ;) u might find it useful.
On Apr 4, 2013 2:19 AM, "Joe Fiorini" notifications@github.com wrote:

@stefanpenner https://github.com/stefanpenner That would be lovely. I'm
past the problems that cause me to open this issue, but I after upgrading
to RC2 I got a host of test failures, mostly tying back to em-data.
Although I might have it all back by Thursday, I'd love to talk anyway just
to see if I'm doing anything crazy and better understand how other people
are testing Ember. Up for that? 9pm EST work for you?


Reply to this email directly or view it on GitHubhttps://github.com/emberjs/data/issues/821#issuecomment-15873657
.

Owner

stefanpenner commented Apr 4, 2013

@joefiorini yes that works for me. stefan.penner@gmail.com <-- gtalk or something me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment