question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ember.get doesn't see Mirage Model attrs

See original GitHub issue

I hit a weird and surprising behavior:

let post = server.find('post', 1);
assert.equal(post.title, "The Title"); // Works
assert.equal(Ember.get(post, 'title'), "The Title"); // Doesn't work

Note that Ember.get is supposed to work on POJOs, and it works on defineProperty getters. But something about Mirage Model is confusing it.

This came up because I was stashing the Model on this in a component integration test, like:

this.set('model', model);
this.render(hbs`{{call-to-action-card teaser=model}}`);
assert.equal(this.$('h1').text(), this.get('model.title'));

And the chained get('model.title') fails.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
samselikoffcommented, Apr 7, 2016

server.create is designed to seed Mirage’s db with models, and the only way those would make it to your Ember app would be through an XHR request. From that perspective, it wouldn’t really make sense to set the return value from server.create on an Ember component.

I think enough people have asked about this though, so I’m open to introducing some helpers that would let you create client-side model instances from Mirage server data. But, no work has started on this yet.

0reactions
marclundgrencommented, Dec 5, 2017

thank you @acorncom

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember.get doesn't see Mirage Model attrs · Issue #583 · miragejs ...
I hit a weird and surprising behavior: let post = server.find('post', 1); assert.equal(post.title, ... Ember.get doesn't see Mirage Model attrs #583.
Read more >
Ember-cli-mirage not showing any data with get - Stack Overflow
First thing first, install Ember inspector extension (for Chrome or Firefox) and look in the browser console to see if Mirage is giving...
Read more >
Models - Ember CLI Mirage
Define models by adding files under /models . These are automatically registered with schema , which is how you'll access your model classes...
Read more >
Test Driving a Stubbed API in Ember with Ember-CLI-Mirage
Ember and Ember Data should be updated. To check, start your ember server and go to localhost:/4200 and you'll see the “Welcome to...
Read more >
Dealing with stale client data | Mirage tips and tricks - EmberMap
Work through a situation where your app falls out of sync with your server while updating a complex relationship.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found