// karma.conf.jsmodule.exports = function(config) { config.set({ preprocessors: { '**/*.html': ['html2js'] }, files: [ '*.js', '*.html' ], html2JsPreprocessor: { // strip this from the file path stripPrefix: 'public/', // prepend this to the file path prependPrefix: 'served/', // or define a custom transform function processPath: function(filePath) { // Drop the file extension return filePath.replace(/\.html$/, '');
How does it work ?
This preprocessor converts HTML files into JS strings and publishes them in the global window.__html__, so that you can use these for testing DOM operations.