设置Jasmine:get undefined不是Jasmine.js中的对象

设置Jasmine:get undefined不是Jasmine.js中的对象,jasmine,karma-jasmine,Jasmine,Karma Jasmine,我正在尝试对jasmine进行初始设置,以便为我的代码编写单元测试。当我运行“karma start unit tests.conf.js”时,我不断遇到以下错误: 我不知道这是什么意思。如果您无法读取错误,则如下所示: PhantomJS 2.1.1 (Windows 8 0/0/0) Error TypeError: undefined is not an object (evaluating 'spacDefinitions.length') at C:/Users/GoogleDri

我正在尝试对jasmine进行初始设置,以便为我的代码编写单元测试。当我运行“karma start unit tests.conf.js”时,我不断遇到以下错误:

我不知道这是什么意思。如果您无法读取错误,则如下所示:

PhantomJS 2.1.1 (Windows 8 0/0/0) Error
TypeError: undefined is not an object (evaluating 'spacDefinitions.length') 
at C:/Users/GoogleDrive/.../node_modules/jasmine-core/lib/jasmine-core/jasmine.js:830
下面是我的配置文件。我没有正确配置它吗?我有什么遗漏吗

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
      'lib/ionic/js/ionic.bundle.js',
      'lib/angular-mocks/angular-mocks.js',
      'js/*',
      'index.controller.js',
      'layout/mainView.directive.js',
    ],


    // list of files to exclude
    exclude: [
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['PhantomJS'],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: false,

    // Concurrency level
    // how many browser should be started simultaneous
    concurrency: Infinity
  })
}

谢谢你的帮助

在您的karma配置中,我在“文件”部分没有看到angular.min.js的条目。将“文件”部分替换为:-

 files: [
   'lib/ionic/js/ionic.bundle.js',
   'lib/angular.min.js',
   'lib/angular-mocks/angular-mocks.js',
   'js/*',
   'index.controller.js',
   'layout/mainView.directive.js',
],
假设angular.min.js放在lib文件夹中。
它应该可以工作。

问题是我的一个测试不完整。我刚刚做了descripe(),结果失败了。我认为这是一个可怕的错误。