Sunday, 25 August 2013

How to set Ember environment variable of in qunit

How to set Ember environment variable of in qunit

I am settingENV.HELPER_PARAM_LOOKUPS = true for Ember.js so the linkTo
helper will perform property look up instead of a hardcoded route. For
example, I could do
The way I set the environment variable is inside the tag of my
application.html.erb layout (I am using rails 4.0 by the way), as follow:
<script type="text/javascript" >
// Ember environment variable
ENV = {
HELPER_PARAM_LOOKUPS: true
};
</script>
However, when I run the qunit test, it gives error as:
The attempt to linkTo route 'view.path.index' failed. The router did not
find 'view.path.index' in its possible routes:
It also gives the deprecation warning:
DEPRECATION: You provided a quoteless destination route parameter of
view.path to the linkTo helper. Soon, this will perform a property lookup,
rather than be treated as a string. To get rid of this warning, wrap
view.path in quotes. To opt in to this new behavior, set
ENV.HELPER_PARAM_LOOKUPS = true
Apparently, qunit is not configuring Ember.js as I intended. How to make
qunit read my environment setting for ember when the test is loaded.
Here is the code in my qunit test:
module("Frontend Test", {
setup: function() {
Ember.run(App, App.advanceReadiness);
},
teardown: function() {
App.reset();
}
});
test("Check HTML is returned", function() {
visit("/").then(function() {
ok(exists("*"), "Found HTML!");
});
});

1 comment:

  1. Really nice blog post.provided a helpful information.I hope that you will post more updates like this Ruby on Rails Online Training India

    ReplyDelete