Creating Test Data in Ember Data 1.0


#1

In Ember Data pre-1.0, you could access createRecord directly from the class being created.

In Ember Data 1.0, you need a store object that is embedded in a controller or route.

Okay, but lets say I want to create a single record for the purposes of unit testing a model – what’s best way to get a data store so that I can create a record? I see the Ember Data tests using a utility method called createStore – is that the way to go? What’s the best way to load that into my tests?


#2

At the moment, I’m using

store = App.__container__.lookup('store:main');

Which I don’t love. Anything better?


#3

I, too, am in need of creating models for the purposes of unit testing…could you provide a real example of what you’re doing with:


#4

Yeah I agree… the App.__container__.lookup('store:main') “idiom” (for want of a better word) either keeps crashing my browser, or is not working at all.

Using Ember Data 1.0.0 I don’t actually know how one can unit test models. This pretty much completely sucks for me because I’m trying to do test driven development and also write some regression tests against some highly recursive data structures. I’ve looked at the ember data source, the ember source and also the disqus source some, but I find them way too complicated for my current level of understanding.