2017-02-18 39 views
0

我正在嘗試初始設置茉莉花來爲我的代碼編寫單元測試。當我運行「業力開始單位tests.conf.js」我一直遇到這樣的錯誤:設置茉莉:獲取undefined不是jasmine.js中的對象

enter image description here

我不知道這意味着什麼。如果你看不懂它的錯誤是這樣的:

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 
    }) 
} 

謝謝任何​​幫助!

回答

0

在你的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文件夾中。 它應該工作。

+0

問題是我的一個測試是不完整的。我只是描述了(),並因此而失敗。我認爲可怕的錯誤。 – MatTaNg

相關問題