Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unloading records in teardown causes intermittent failure #73

Closed
digitalcora opened this issue Apr 15, 2015 · 2 comments
Closed

Unloading records in teardown causes intermittent failure #73

digitalcora opened this issue Apr 15, 2015 · 2 comments

Comments

@digitalcora
Copy link

The new documentation in the README includes this part about acceptance testing:

  teardown: function () {
    Ember.run(function () {
      TestHelper.teardown();
      App.destroy();
    });
  }

As part of the TestHelper.teardown call, Factory Guy unloads all records from the store. The problem is that the app is still running at this point, and App.destroy is asynchronous and does not destroy the app immediately. Unloading the records can therefore raise errors (e.g. in computed properties that depend on associations) and cause tests to fail.

The thing is, App.destroy seems to already unload all records from the store. I tested this by commenting out the teardown line, and observing that the count of local records was reset to 0 by the time each new test started. I am not using the fixture adapter so maybe things would be different there, but in my case I was able to replace TestHelper.teardown() with a simple $.mockjax.clear() (since that is the other thing the teardown call does), and that resolved the intermittent failures.

I'm not sure if this means the record unloading could safely be removed for everyone, just noting that it caused a problem for me and doesn't seem to be strictly necessary.

@danielspaniel
Copy link
Collaborator

That is so puzzling Alex, because I could swear I remember trying that ( just calling destroy ) .. and not using teardown to clear the models. But maybe I didn't .. anyway .. that's a good find, and I will check that out and take out clearing store from teardown if the tests pass for that.
Thanks for the info.

@danielspaniel
Copy link
Collaborator

You were right @Grantovich. The store is cleared in App.destroy. Can not believe I did not catch that one.
New version 1.0.3 no longer clears store in TestHelper.teardown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants