Ember.get doesn't see Mirage Model attrs
See original GitHub issueI 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:
- Created 8 years ago
- Comments:10 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 fromserver.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.
thank you @acorncom