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 - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -