# How to load proxy relationships in Ember testing

**URL:** <https://discuss.emberjs.com/t/how-to-load-proxy-relationships-in-ember-testing/18899>\
**Category:** Ember Data\
**Created:** [June 3, 2021, 6:40pm UTC](https://discuss.emberjs.com/t/how-to-load-proxy-relationships-in-ember-testing/18899 "2021-06-03T18:40:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sesquibel](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/sesquibel/32/17476_2.png) [@sesquibel](https://discuss.emberjs.com/u/sesquibel)\
**Post date:** [June 3, 2021, 6:40pm UTC](https://discuss.emberjs.com/t/how-to-load-proxy-relationships-in-ember-testing/18899/1 "2021-06-03T18:40:34Z")

</div>

I am trying to test whether a model gets hydrated with the appropriate data, but I am getting proxy objects back in regards to relationship models (belongsTo, hasMany) instead of the model itself. I have tried creating the model with the data, “get”-ing the models after the fact, and creating new model instances, and then setting them on the model, but it always returns a proxy object.

Does anyone have any guidance on this issue? I saw another thread similar to this ([Ember Data Proxy BelongsTo](https://discuss.emberjs.com/t/ember-data-proxy-belongsto/16327)) but I wanted to see if there were any fresh ideas.

 ![ember-discuss-0](https://us1.discourse-cdn.com/flex019/uploads/emberjs_public/original/3X/0/9/090529edf2983215b2f482703a7f03d7a3dd8705.png)

---

<div class="post-metadata">

**Author:** ![dknutsen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dknutsen/32/16471_2.png) [@dknutsen](https://discuss.emberjs.com/u/dknutsen)\
**Post date:** [June 3, 2021, 6:59pm UTC](https://discuss.emberjs.com/t/how-to-load-proxy-relationships-in-ember-testing/18899/2 "2021-06-03T18:59:41Z")

</div>

If the relationships are “async” (which they are by default) they will always return proxies. There are a few things you could do if you don’t want to deal with the proxies…

- convert the relationships to synchronous ([some would argue](https://embermap.com/notes/83-the-case-against-async-relationships) this should be the default) but this may require a broader rethinking of your data fetching patterns
- “unwrap” it by waiting for it with `await` (async function, e.g. in a test like you want to do) or `yield` (ember concurrency task) e.g. `await model.relationshipName`
- use the lower level relationship APIs to get the relationship value synchronously, e.g. `model.belongsTo('relationshipName').value()`
- refer to the proxy `content` (i don’t really recommend this) e.g. `model.relationshipName.content`

Relevant pages from the docs:

- [Relationships - Ember Data - Ember Guides](https://guides.emberjs.com/release/models/relationships/#toc_relationships-as-promises)
- [BelongsToReference - 3.26 - Ember API Documentation](https://api.emberjs.com/ember-data/3.26/classes/BelongsToReference/methods/value?anchor=value)
- [belongsTo - 3.26 - Ember API Documentation](https://api.emberjs.com/ember-data/3.26/functions/@ember-data%2Fmodel/belongsTo)

---

<div class="post-metadata">

**Author:** ![sesquibel](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/sesquibel/32/17476_2.png) [@sesquibel](https://discuss.emberjs.com/u/sesquibel)\
**Post date:** [June 3, 2021, 11:36pm UTC](https://discuss.emberjs.com/t/how-to-load-proxy-relationships-in-ember-testing/18899/3 "2021-06-03T23:36:52Z")

</div>

Thank you for the quick reply! Unfortunately, only the last option worked so I am trying to go about it a different way.
