【问题标题】:"Moment cannot be found by angular-moment" when trying to test with karma & jasmine - AngularJS尝试用业力和茉莉花进行测试时,“角矩无法找到矩”-AngularJS
【发布时间】:2018-07-10 12:29:36
【问题描述】:

我的应用运行正常,AngularMoment 与 MomentJS 完美配合。

最近我尝试使用 Karma 和 Jasmine 在 grunt watch 上的应用中实现 单元测试。所有模块似乎都可以正常加载,但angular-moment 找不到只有moment(错误信息如下):

Error during loading: Uncaught Error: Moment cannot be found by 
angular-moment! Please reference to: https://github.com/urish/angular- 
moment in js/libs/angular-moment.js line 27

所有依赖项都加载到karma.config.js 中,但仍然无法正常工作。

【问题讨论】:

    标签: angularjs gruntjs momentjs karma-jasmine angular-moment


    【解决方案1】:

    karma.config.js 中文件的顺序很重要。我们必须先加载某些库,如下所述。

    files: [
        //Dependencies of the app
        'dist/js/libs/jquery.js',
        'dist/js/libs/angular.js',
        'dist/js/libs/angular-mocks.js',
        'dist/js/libs/moment.js',
        'dist/js/libs/*.js',
        .
        .
        .
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-26
      • 2023-04-06
      • 2020-03-27
      • 2017-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      相关资源
      最近更新 更多