Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't find haml-js templates during Jasmine test run
    text
    copied!<p>I'm trying to test some backbone.js views using Jasmine (via jasmine-headless-webkit). Everything is working well, except that my haml-js templates aren't accessible under test.</p> <p>The following code in my view works fine:</p> <p></p> <pre><code>render: =&gt; html = JST['views/avia_view_template']() $(@el).html(html) </code></pre> <p>... but when it's run as part of a Jasmine spec I get the following failure:</p> <pre><code>ReferenceError: Can't find variable: JST in /home/duncan/avia/app/assets/javascripts/views/avia_view.js.coffee </code></pre> <p>I suspect I'm doing something wrong in <code>jasmine.yml</code>. I've explicitly included the template file it still fails:</p> <p></p> <pre><code>src_files: - "vendor/**/*.{js,coffee}" - "lib/**/*.{js,coffee}" - app/assets/javascripts/application.js - app/assets/javascripts/avia.js - app/assets/javascripts/jquery-1.6.4.js - app/assets/javascripts/underscore.js - app/assets/javascripts/backbone.js - app/assets/javascripts/jquery.jqGrid.min.js - app/assets/javascripts/views/avia_view_template.jst.hamljs - app/assets/javascripts/views/avia_view.js.coffee </code></pre> <p>Perhaps I'm just taking the wrong approach here ... should I be using Jasmine to stub &amp; mock out the calls to JST and jQuery? A strictly unit-testing approach says I should, in which case the lack of template access is a non-issue.</p> <p>Any tips - either on my approach to testing, or the specific JST failure, would be greatly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload