How to get data from store.find() inside test() in Ember application while testing


#1

I want to test general retrieving data from DS.Store.

For that i want to write inside my test something like

test("Load categories", function(assert){
    App.store.find('data').then(function (data){
        ok(data,'data ok')
    });
});

The problem is that in Ember-testing promises works not like expected and the hook inside then doesn`t run.

Haw can i organize my code to get my data from the store?


#2

The problem was that I setup the store incorrectly

module("Data testing",
    setup:  ->
        Ember.run App, ->
            App.reset()
            DS.Store.create()
            @store = containerLookup('store:main')

so, deleted declaration of the store in setup()

module("Data testing",
    setup:  ->
        Ember.run App, ->
            App.reset()

and moved it inside test()

test("Load categories", (assert) ->
    store = containerLookup('store:main')
    store.find('category').then( (data)->
        ok(data, 'data is here')

After that then() function runs.