Extract Data from Model in Ember 2

Is it possible to retrieve Model data from an existing Ember application (ember version >= 2.10) without altering the app's source code?

For instance, I need to create Selenium tests for my user interface built on Ember. However, certain initialization code relies on Models in Ember. Is there a way to obtain these models using a Javascript script?

Answer №1

Accessing the store from outside its namespace is restricted. This means that without access to an Ember container, you will not be able to locate the store.

To work around this limitation, one might consider implementing a hack in the source code by setting the main App store as a global property (although this is not recommended due to potential memory leaks) and then using that global store within their test suite.

It is advised to utilize Embers well-designed Acceptance tests instead:

If one does have access to the App instance, they can simply do the following:

var store = App.__container__.lookup('store:main');
var post = this.store.peekRecord('post', 1); // => no network request

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Setting up grunt-contrib-nodeunit to generate JUnit XML output: a step-by-step guide

I have been searching for information on how to configure reporters in the grunt-contrib-nodeunit module, as I recently added this task to my Gruntfile.js. nodeunit: { all: ['nodeunit/**/*.test.js'], } Does anyone know how to instruct Grunt ...

Modify the text on a button in ReactJS upon clicking

I am trying to change the text of a button when it is pressed. My goal is to achieve something similar to this example: https://codepen.io/gaearon/pen/xEmzGg?editors=0010, but I am having trouble getting my code to work (I'm new at this). class Obje ...

jQuery fails to execute in ajax success function

Currently, I am using jQuery and Ajax to dynamically populate a select element. However, I am facing an issue within my success callback where my DOM manipulation is being ignored. An interesting observation is that even though my console.log('test&a ...

Safari browser not triggering the ready function

Why does the "ready" function not work in Safari but works in Firefox, Internet Explorer, and Chrome? More information: JQuery.js is included in the parent page which is why it is not necessary to include it in my page. $(document).ready(function () { h ...

Trouble with clicking the button in Selenium Webdriver? Element located but unable to be clicked

Can anyone assist me in finding a solution to my current problem? I have dedicated a significant portion of today trying various solutions both on this platform and through Google. To get straight to the point, I am facing an issue with Selenium automatio ...

How can we stop KeyboardAvoidingView in React Native from overlapping content?

I'm working on implementing a KeyboardAvoidingView section for a signup form. I've managed to adjust the keyboard properly on both iOS and Android, but instead of increasing the view's height and scrolling up, the KeyboardAvoidingView is red ...

The combination of Angular Hottowel's 'blocks.exception' and 'blocks.router' prevents the App from being displayed in the browser

After delving into Angular's fundamentals a couple of months back, I am now venturing into building a practice app that mirrors industry standards. I recently completed John Papa's Play by Play and Clean Code courses on Pluralsight, which furthe ...

Difficulty accessing `evt.target.value` with `RaisedButton` in ReactJS Material UI

My goal is to update a state by submitting a value through a button click. Everything works perfectly when using the HTML input element. However, when I switch to the Material UI RaisedButton, the value isn't passed at all. Can someone help me identif ...

Is there a way to configure my v-text-field so that it does not display negative numbers?

I want to only allow positive numbers in my <v-text-field>. Is there a way to achieve this using props or any other method? Below is the code snippet: <v-text-field :value="0" class="mr-0 pt-0" hide-details single-line ...

Hold on for the asynchronous operation to complete before redirecting in KoaJS

Currently, I am facing a challenge in spawning a child process to manage some POST data in NodeJS (utilizing the Koa framework). My goal is to wait for the child process to complete before redirecting, but due to the asynchronous nature of the child proce ...

Is it possible to zoom the browser window using Python's Selenium WebDriver?

I'm attempting to ZOOM IN and ZOOM OUT in Chrome (using selenium webdriver) solely with the keyboard. I've attempted the following: from selenium.webdriver.common.keys import Keys driver.find_element_by_tag_name("body").send_keys(Keys.CONTROL,Ke ...

What is the best way to restore a minimized selenium window?

While there are numerous resources available that offer guidance on minimizing browser windows opened with Selenium, I have yet to come across a guide for un-minimizing a minimized window. I am not looking to maximize the window. Rather, I aim to restore ...

JavaScript maintain a variable that holds onto nodes even after they have been removed

Recently, I encountered a seemingly simple issue with JavaScript that has me stumped. In my code, I have a variable that stores nodes with a specific class. My goal is to remove these nodes from the DOM while still retaining them in the variable. However, ...

Establish a secure connection to MySQL through SSH tunneling with node-mysql

Is it feasible to establish a connection to the MySQL server using an SSH key instead of a password when utilizing the node-mysql npm package? ...

TypeScript struggling to recognize specified types when using a type that encompasses various types

I have a defined type structure that looks like this: export type MediaProps = ImageMediaProps | OembedProps; Following that, the types it references are defined as shown below: type SharedMediaProps = { /** Type of media */ type: "image" | "oembed"; ...

"Explore stunning images with the power of JavaScript in our

My question involves a div containing five images, displayed in order as [1] [2] [3] [4] [5]. I am looking to create a JavaScript script that will automatically rearrange the images to display them as [2] [3] [4] [5] [1], then [3] [4] [5] [1] [2], and so o ...

Tips for preventing HTML ID clashes while integrating with the Document Object Model of external websites

When incorporating additional HTML elements into a webpage using Javascript or jQuery, along with external CSS declarations, it is important to avoid conflicts with existing IDs and class names already present on the page. This could lead to issues if ther ...

Creating interactive visuals using black circles in a 360 video with the help of three

I am facing an issue with my 360 video player created using three.js. The player works perfectly when the video ratio is 1:2, however, for videos with a ratio of 9:16, I see two black circles appearing on the top and bottom of the sphere. Below are the co ...

Audio support across multiple channels on iOS and Android web browsers

After stumbling upon a helpful link to a page here on StackOverflow discussing "Creating Audio using Javascript in <audio>", and also finding a resource on another website detailing how to play audio on multiple channels, I have come across a questio ...

Extract all content from a Div following a hyphen and stop at the first character

I'm currently attempting to create a function that can locate specific text within a div and then display all the text that comes after the '-' character in the console. There may be instances where there are spaces or tabs following the &ap ...