简单的Karma-RequireJS-Jasmine配置失败

时间:2015-01-23 08:14:31

标签: requirejs karma-jasmine

我有以下简单配置。 我的源代码是简单的JavaScript。没有图书馆或模块或其他任何东西。 似乎有一个特定的加载东西的顺序,即使是一个简单的测试系统也似乎很棘手。

即使Karma正常启动,我的规范也都没有执行。可能是什么问题?

我的test-main.js就是这个。

var tests = ['bootstrap'];
for (var file in window.__karma__.files) {
if (/spec\.js$/.test(file)) {
    tests.push(file);
    console.log('[' + file + ']');
}
};


require.config({


// Karma serves files from '/base'
baseUrl: '/base/src',

paths: {
    'individual': 'individual',
    'demographic': 'demographic',
    'tradingpartner': 'tradingpartner',
    'enrollmentstate': 'enrollmentstate',
    'affiliation': 'affiliation',
    'address': 'address',
    'provider': 'provider',
    'transactionmessage': 'transactionmessage',
    'transactionformat': 'transactionformat',
    'jquery': '../lib/jquery',
    'bootstrap': '../lib/bootstrap',
   },
    shim: {
    'bootstrap':{
        deps: ['jquery']
    },
    'individual':{
        deps: ['demographic']
    },
    'business':{
        deps:['demographic']
    },
    'tradingpartner':{
        deps:['enrollmentstate']
    },
    'tradingpartner':{
        deps:['affiliation']
    }               
},

 // ask Require.js to load all the test spec files
//deps: filesToLoad
  deps: tests,

// kickoff jasmine tests from karma, once require loading is complete
callback: window.__karma__.start
});

我的karma.conf.js就是这个

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

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


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


  // list of files / patterns to load in the browser
files: [
    {pattern: 'lib/**/*.js', included: false},
    {pattern: 'src/**/*.js', included: false},
    {pattern: 'spec/**/*Spec.js', included: false},

    'test/test-main.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_DEBUG,


// 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: ['Chrome'],


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

// required plugins to run unit testing using Karma & jasmin
plugins: [
  'karma-jasmine',
  'karma-requirejs',
  'karma-junit-reporter',
  'karma-commonjs',
  'karma-coverage',
  'karma-ng-html2js-preprocessor',
  'karma-chrome-launcher',
  'karma-firefox-launcher',
  'karma-safari-launcher',
  'karma-ie-launcher',
  'karma-opera-launcher',
  'karma-phantomjs-launcher',
  'karma-htmlfile-reporter'
]

 });
};

0 个答案:

没有答案