本文介绍了未捕获的错误:模块名称&"lib/chai& quot;尚未加载上下文:使用require([])的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用karma-mocha ..my karma.conf文件正在使用karma-jasmine ...,但不适用于karma-mocha .... my karma.conf文件:-

i m using karma-mocha ..my karma.conf file is working with karma-jasmine...but not working with karma-mocha....my karma.conf file:--

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

    basePath : '../app',

    preprocessors: {
      '**/*.html':'ng-html2js'
    },

    ngHtml2JsPreprocessor: {
      prependPrefix: '/'
    },

    files : [
    'node_modules/jquery/**/*.js',
      'lib/angular/angular.js',
      'lib/angular/angular-*.js',
      '../test/lib/angular-mocks.js',
      '../test/lib/sinon-1.15.0.js',
      '../test/chai/chai.js',
      'js/**/*.js',
      '../test/unit/**/*.js',
      '**/*.html'
    ],

    autoWatch : true,

    frameworks: ['mocha','requirejs','chai'],

    browsers : ['Chrome'],

    plugins : [
      'karma-chrome-launcher',
      'karma-mocha',
      'karma-ng-html2js-preprocessor',
      'karma-requirejs',
      'karma-chai'
    ],

    junitReporter : {
      outputFile: 'test_out/unit.xml',
      suite: 'unit'
    }

  });
};

推荐答案

您缺少chai lib路径files array,该路径依赖于mocha.include它.

you are missing chai lib path files array in which is dependency to mocha.include it.

files : [
        'node_modules/jquery/**/*.js',
          'lib/angular/angular.js',
          'lib/angular/angular-*.js',
          '../test/lib/angular-mocks.js',
          '../test/lib/sinon-1.15.0.js',
          '../test/chai/chai.js',
          'js/**/*.js',
          '../test/unit/**/*.js',
          '**/*.html'
        ],

这篇关于未捕获的错误:模块名称&"lib/chai& quot;尚未加载上下文:使用require([])的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 13:59