角度1.5 ng物料业力单元测试

时间:2019-11-08 19:42:48

标签: angularjs karma-jasmine angularjs-material

我在使用AngularJS 1.5版本的应用程序中引入了ngMaterial。一切看起来不错,但因果测试案例失败,并显示消息

  

“错误:[$ injector:nomod]模块'ngMaterial'不可用!您拼错了模块名称或忘记了加载它。”

下面是我的代码。有人可以帮助解决此错误。

(function (angular) {
  'use strict';

  var myComponentComponent = {
    templateUrl: 'app/myComp/myComp.html',
    controller: myComponentController,
    controllerAs: 'vm'
  };

  /* @ngInject */
  function myComponentController($sce, $templateCache, viewport) {
    var vm = this;

  }

  angular.module('core', ['ngMaterial', 'ngMessages'])
    .component('myComponent', myComponentComponent);

})(angular);

describe('testCore', function () {
  beforeEach(module('core'));
  beforeEach(module('ngMaterial'));
  beforeEach(module('ngMessages'));

  var $window;
  var $componentController;
  var scope;
  var $rootScope;
  var controller;

  beforeEach(inject(function (_$window_, _$componentController_, _$rootScope_) {
    $window = _$window_;
    $componentController = _$componentController_;
    $rootScope = _$rootScope_;
    scope = $rootScope.$new();
    controller = $componentController('myComponent', null, scope.mockData);
    scope.$apply();
  }));



  it('should initialize component', function () {

  });


});

0 个答案:

没有答案