单元测试角度应用程序与breezejs

时间:2016-08-02 09:46:32

标签: angularjs unit-testing breeze karma-jasmine

我正在尝试使用Angular应用程序设置单元测试,该应用程序利用breezejs库进行odata查询。当使用Karma运行我的测试时,breeze库似乎尝试进行配置设置,我不想发生这种情况。我正在使用角度模拟来模拟模块,但似乎entityManagerFactory运行并尝试配置breeze。这是karma.conf设置

files: [
  // 'www/Scripts/**/*.js',
  // 'www/**/*.js',
  'www/Scripts/angular.js',
  'www/Scripts/angular-animate.min.js',
  'www/Scripts/angular-translate.min.js',
  'www/Scripts/angular-route.js',
  'www/Scripts/angular-messages.js',
  'www/Scripts/angular-sanitize.min.js',
  'www/Scripts/angular-resource.js',
  'www/Scripts/naturalSort.js',
  'node_modules/angular-mocks/angular-mocks.js',
  'www/Scripts/jquery-1.10.2.js',    
  'www/Scripts/breeze.min.js',  
  'www/Scripts/breeze.debug.js',
  'www/Scripts/breeze.directives.js',
  'www/Scripts/breeze.bridge*.js',
  'www/app.module.js',
  'www/data/**/*.js',
  'www/core/**/*.js',
  'www/blocks/**/*.js',
  'www/common/**/*.js',
  'www/features/**/*.js',
  'test/unit/**/*Spec.js',
],

运行“karam start”时出现以下错误

Error: Unable to initialize OData.  Needed to support remote OData services
        at Object.__requireLib [as requireLib] (www/Scripts/breeze.debug.js:410:11)
        at webApiODataCtor.proto.initialize (www/Scripts/breeze.debug.js:16284:18)
        at initializeAdapterInstanceCore (www/Scripts/breeze.debug.js:1874:14)
        at Object.__config.initializeAdapterInstance (www/Scripts/breeze.debug.js:1795:12)
        at configureBreeze (www/data/entityManagerFactory.js:46:41)
        at Object.emFactory (www/data/entityManagerFactory.js:16:9)
        at Object.invoke (www/Scripts/angular.js:4182:17)
        at Object.enforcedReturnValue [as $get] (www/Scripts/angular.js:4035:37)

entityManagerFactory在加载配置breeze时调用一个函数(configureBreeze();),这一定是问题

  function emFactory(breeze) {
    configureBreeze();
    var oldClient = null;

    var factory = {
        newManager: newManager,
        serviceName: eCAT_ServiceName,
        setAuthToken: setAuthToken
    };

    return factory;

0 个答案:

没有答案