【发布时间】:2016-03-02 20:28:14
【问题描述】:
我刚刚开始使用 Karma 设置一些测试。我使用 jdDom 进行了一些测试,但不喜欢它的配置方式。但是,我不确定如何正确指向 js 文件。当我收到此错误时
Error: [$injector:modulerr] Failed to instantiate module ha.module.utility due to:
Error: [$injector:nomod] Module 'ha.module.utility' 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.
我用 jsdom 启动了一个需要核心模块的文件
require('../../../src/modules/core/module.core.built.js'); 要求('../../../src/modules/utility/module.utility.built.js');
这些脚本是我的模块所在的位置。我不确定将它们放在 karma 文件中的哪个位置。 或者如果这甚至是问题。这是我下面的业力文件。我删除了 karma init 附带的 cmets,以便可以更快地阅读这篇文章。
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: 'Scripts/',
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'jquery /jquery libraries ',
'../node_modules/angular/angular.js',
'../node_modules/angular-mocks/angular-mocks.js',
'test2/*.js',
'tests/**/*.js'
],
exclude: [
'tests/old/**',
'tests/**/*.setup.js'
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'../Templates/**/*.html' : ['ng-html2js']
},
ngHtml2JsPreprocessor: {
// setting this option will create only a single module that contains templates
// from all the files, so you can load them all with angular.mock.module('foo')
//stripPrefix: "Templates/",
//prependPrefix: "Templates/",
moduleName: 'templates'
},
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: true,
concurrency: Infinity
基本上我需要这些测试来找到模块。
【问题讨论】:
标签: karma-runner karma-jasmine