Allows for javascript template engines to be used within jasmine

npm install grunt-template-jasmine-templates
4 downloads in the last month

Handlebars/Underscore template for Jasmine unit tests

Build Status

Allows for javascript template engines to be used within jasmine


npm install grunt-template-jasmine-templates --save-dev

Template Options


Type: String or Array Options: path to, or globbing patterns Default: none

The vendor to use. Handlebarjs and Underscore are both pre-saved in the vendor folder

Sample usage

// Example configuration using a single requireJS config file
  jasmine: {
    templates: {
      src: 'src/**/*.js',
      options: {
        specs: 'spec/*Spec.js',
        host: '',
        template: require('grunt-template-jasmine-templates'),
        templateOptions: {
          vendor: 'vendor/**/*.js',
          templates: 'src/**/*.tmpl'

Note that you would need grunt-contrib-connect

Your *Spec file could look something like this:

describe("Handlebars templating", function() {

  // If you're trying to use a template named handlebars.tmpl,
  // it will be accessible via its id handlebars_tmpl
  var template = document.getElementById("handlebars_tmpl").innerHTML;

  it("has access to the template", function(){
    var compiledTemplate = Handlebars.compile(template);

    // Let's create some nodes from the template
    var el = document.createElement("div");
    el.innerHTML = compiledTemplate;
    el = el.children[0];

    // Let's now test these nodes

npm loves you