Is there any way to extract Model data from existing Ember app (ember version >= 2.10) without any changes in app's sources.
For example I want to have some Selenium test for my UI based on Ember. And some of my initialization code depends on Models in Ember. Can I extract this models via some pretty JS script?
You cannot access the store
from outside its namespace. Meaning if you dont have access to an Ember container
you will not be able to look up the store
.
You would have to modify the source code to do something hacky like setting the main App store
as a global property (not recommended as it can lead to memory leaks) and accessing that global store
with your test suite.
Recommended: rely on Embers well thought Acceptance tests: https://guides.emberjs.com/v2.11.0/testing/acceptance/
If you did have access to the App
instance you could simply:
var store = App.__container__.lookup('store:main');
var post = this.store.peekRecord('post', 1); // => no network request