angularjs - karma-ng-html2js-preprocessor not working gulp + angular + karma + ng-html2js -



angularjs - karma-ng-html2js-preprocessor not working gulp + angular + karma + ng-html2js -

i can't create karma-ng-html2js-preprocessor working external template.

package json file:

..... "gulp-karma": "*", "karma-coverage": "*", "karma-jasmine": "*", "karma-ng-html2js-preprocessor": "*", "karma-phantomjs-launcher": "*", .....

karma config file:

config.set({ browsers: [ .... ], frameworks: [ 'jasmine' ], plugins: [ 'karma-jasmine', 'karma-phantomjs-launcher', 'karma-ng-html2js-preprocessor' ], preprocessors: { 'app/**/*.html': 'ng-html2js' }, nghtml2jspreprocessor: { stripprefix: 'app/' } });

files defined in build file , passed gulp-karma. here defined files:

config = { test: { configfile: '.../karma.conf.js', depends: [ ....... ], files: [ "app/**/*.js", 'app/**/*.html' ] } }

loading template in directive spec below:

beforeeach(module('app')); beforeeach(module('app/tem/mytemp.html'));

i getting error below:

error: [$injector:modulerr] failed instantiate module app/tem/mytemp.html due to: error: [$injector:nomod] module 'app/tem/mytemp.html' not available! either misspelled

in karma debug.html html files loaded in link tag output:

<script type="text/javascript" src="/absolutec:.../app/tem/comp/mydirective.js"></script> <link href="/absolutec:..../app/tem/mytemp.html" rel="import"> <script type="text/javascript"> window.__karma__.loaded();

am missing anything? how debug , move forwards issue?

here how solved exact same problem:

1) npm install karma-ng-html2js-preprocessor --save-dev (you have done that)

2) in karma.config.js:

// .... preprocessors: { '**/*.html': ['ng-html2js'] }, // .... nghtml2jspreprocessor: { stripprefix: 'app/', // <-- alter needed project // include beforeeach(module('templates')) in unit tests modulename: 'templates' }, plugins : [ 'karma-phantomjs-launcher', 'karma-jasmine', 'karma-ng-html2js-preprocessor' ]

3) since gulp-karma overwrites files property of karma.conf.js, change gulp task config test setup(s) (i had two: 1 test runs tests 1 time , called tdd continuous testing) this:

gulp.task('test', function() { var bowerdeps = ... var testfiles = bowerdeps.js.concat([ 'app/scripts/**/*.js', 'test/unit/**/*.js', 'app/**/*.html' // <-- need add together load .html files ]); homecoming gulp.src(testfiles) .pipe($.karma({ configfile: 'test/karma.conf.js', action: 'run' })) .... });

hope help someone.

angularjs karma-jasmine ng-html2js gulp-karma

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -