Karma angular 测试未能实例化模块

Karma angular testing failed to instantiate module

我刚刚开始使用 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'); require('../../../src/modules/utility/module.utility.built.js');

这些脚本是我的模块所在的位置。我不确定将它们放在业力文件中的什么位置。 或者如果这甚至是问题 。下面是我的业力文件。我删除了 karma init 附带的注释,以便可以更快地阅读此 post。

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 

基本上我需要这些测试来找到模块​​。

您的模块的指令、控制器和所有其他必需的文件应该像这样上传到您的 "files," 列表中:

files: [
    '../node_modules/angular/angular.js',
    '../node_modules/angular-mocks/angular-mocks.js',
    '../../../src/modules/core/module.core.built.js',
    '../../../src/modules/utility/module.utility.built.js',
    'test2/*.js',
    'tests/**/*.js'

],