karma-furnace-preprocessor

A Karma plugin. Convert code from one format to another (like grunt-furnace)

npm install karma-furnace-preprocessor
7 downloads in the last month

karma-furnace-preprocessor

A Karma plugin. Convert code from one format to another (like grunt-furnace)

Installation

The easiest way is to keep karma-furnace-preprocessor as a devDependency in your package.json.

{
  "devDependencies": {
    "karma": "~0.10",
    "karma-furnace-preprocessor": "~0.1"
  }
}

You can simple do it by:

npm install karma-furnace-preprocessor --save-dev

Configuring Karma

// karma.conf.js
module.exports = function(config) {
    config.set({
        preprocessors: {
            'test/tpl/**/*.tpl': ['furnace[tpl>amd]']
        },
        files: [
            { pattern: 'js/**/*.js', included: false },
            { pattern: 'test/**/*.tpl', included: false },
            "test/config.js",
            "test/tests.js"
        ]

Configuring oz.js

Also see karma-ozjs

// test/config.js
require.config({
    // Karma serves files from '/base'
    baseUrl: 'base/js/vendor/',
    aliases: {
        'test': '../../test/',
        'appname': '../appname/'
    }
});

Using template in tests

<!-- test/tpl/demo.tpl --> 
<div class="{%= className %}">
    {%= content %}
</div>
// test/tests.js
require([
    'mo/template'
    'test/tpl/demo',
    'appname/app'
], function(tpl, tpl_demo, app){

    describe('demo', function(){
        before(function(){
            $(tpl.convertTpl(tpl_demo.template, {
                className: 'appname',
                content: '...'
            })).appendTo('body');
        })
        // it(...)
    });

});

Source code

More References

Release History

See OzJS Release History

License

Copyright (c) 2010 - 2013 dexteryy
Licensed under the MIT license.

npm loves you