karma-ng-html2js-preprocessor icon indicating copy to clipboard operation
karma-ng-html2js-preprocessor copied to clipboard

Module is not created for external templates

Open perezperret opened this issue 9 years ago • 3 comments

I am using JSPM, so my config is a bit different from the usual examples. In my karma.config.j file I am loading the templates the following way:

...    
    jspm: {
        loadFiles: [
            'spec/**/*.spec.js',
            'dist/app.js',
        ],
        serveFiles: [
            'dist/**/*.html',
            'dist/**/*.js',
            'dist/**/*.js.map',
        ],
    },
...

And configuring the plugin this way:

...   
    preprocessors: {
        'dist/**/*.html': ['ng-html2js']
    },

    ngHtml2JsPreprocessor: {
        moduleName: 'templates'
    },
...

When I run karma with debug-level logging I can see the correct templates being processed, but I can't mock them in the tests using the module name (angular.mock.module('templates')) nor in the debugger.

For reference I am running OS X 10.10.5, Chrome 48.0.2564.97 (64-bit) and Firefox 30.0.0.

perezperret avatar Feb 04 '16 20:02 perezperret

For further reference, this issue was solved by moving the html files to ...jspm: {loadFiles: ..., which probably makes sense

perezperret avatar May 20 '16 22:05 perezperret

Just had the exact same issue with same solution.

It makes sense that the html must be served correctly, but had a hard time realising that this could in any way be a reason for the preprocessor not to create the 'templates' module? I would have expected to find my solution elsewhere.

cyrixmorten avatar Aug 15 '16 08:08 cyrixmorten

Thanks @perezperret , had the exact same problem here with JSPM

That-David-Guy avatar Nov 29 '16 06:11 That-David-Guy