1

I am writing qunit tests for an ember controller. In my real application I get routed from another page and get data. But, while writing tests I am having trouble getting the data from Ember data store as it sends an asynchronous call and tests run and fail till it gets the data. Any way to force ember store to return the data in the same run loop? Or is there any other way to do it?

1 Answer 1

2

Do you use the FixtureAdapter ? If not, you can try it, and set its simulateRemoteResponse property to false. Your store in tests could be like

var store = DS.Store.create({
               revision: 4,
               adapter: DS.FixtureAdapter.create({simulateRemoteResponse: false}),
               // perhaps other custom properties
            });
Sign up to request clarification or add additional context in comments.

4 Comments

In that case I will have to create fixtures for ember models. What if I want to communicate to the backend (the actual db) to retrieve the records?
In that case I think this not a qunit test for an ember controller, but more a integration test with the full stack. I mean a very higher level test. Perhaps I'm wrong, it would be great to have others advices
Well, I think your suggestion of having a fixtureAdapter was correct. I am using that now. I have another issue there. I am not able to get data of associated models. I have 2 models A and B. A hasMany(B) and B belongsTo(A). I can access B from A but not vice versa. The models are defined properly. What might be happening?
I need some code here ;), in particular how you populate your FIXTURES. Could you update your question with that code ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.