I have been utilizing the npm package karma-ng-html2js-preprocessor
to achieve this task.
This is the content of my spec file:
describe('Directive: aGreatEye (external)', function() {
var elm, scope;
beforeEach(module('my-thing.template.html'));
beforeEach(module('templates'));
beforeEach(inject(function($rootScope, $compile) {
elm = angular.element('<a-great-eye></a-great-eye>');
scope = $rootScope;
$compile(elm)(scope);
scope.$digest();
}));
it('should execute first directive unit test correctly', function() {
// add your assertions here
});
});
However, I encountered an error message stating
Error: [$injector:modulerr] Failed to instantiate module my-thing.template.html due to:
Error: [$injector:nomod] Module 'my-thing.template.html' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Even though the URL seems correct based on the basePath
specified in the karma.config.js
file.
Below is the content of my karma.config.js file:
module.exports = function (config) {
// VIEW ONLINE AT: MAIN_ROOT/tests/jasmineReport/
// You can either run via WebStorm or go online to do tests
config.set({
basePath: '.',
frameworks: ['jasmine'],
files: [
// Vendor Files
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/angular-ui-router/release/angular-ui-router.js',
'bower_components/angular-filter/dist/angular-filter.js',
'bower_components/angular-sanitize/angular-sanitize.js',
'bower_components/lodash/lodash.min.js',
// App-Specific Files
'app/index.js',
'app/common/models/*.js',
'app/common/directives/*.js',
'app/common/filters/*.js',
'app/main/main.js',
// App-Specific HTML Templates
'*.html',
'*.html.ext',
// Test-Specific Files
'tests/mock/**/*.js'
],
exclude: [],
preprocessors: {
// HTML to JavaScript Preprocessors for
// AngularJS Template Directives
'*.html': ['ng-html2js']
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: true,
concurrency: Infinity,
// NgHTML 2 JS Pre-Processor - OPTIONS
ngHtml2JsPreprocessor: {
stripPrefix: 'public/',
stripSuffix: '.ext',
prependPrefix: 'served/',
moduleName: "templates"
}
})
};
What am I missing here?