Karma - Unexpected token when including an html file -


i'm trying include simple html file in karma config file access html elements javascript files , test jasmine in karma.

but i'm getting unexpected token < error. saw in webcast possible include html files, don't know why doesn't works configuration?

thanks in advance

you need use html2js preprocessor (or ng-html2js preprocessor if using angularjs). see preprocessor description how works.

since karma 0.10, html2js preprocessor shipped karma , configured default:

module.exports = function(config) {   config.set({     files: [       'templates/*.html'     ],     preprocessors: {       '**/*.html': ['html2js']     }   }); }; 

then can access html content js string:

var elm = $(__html__['templates/x.html']) 

the error getting means html files not preprocessed. default, html files under basepath preprocessed, maybe html files somewhere else, in case need put them in preprocessors config explicitly. share karma.conf.js if need more help.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -