2017-10-08 36 views
-1
  • 我想学习角js和茉莉花测试用例。
  • 所以我拿了一个样本茉莉花测试用例,并在我的代码示例测试用例小提琴
  • 中使用它,但在我的小提琴中,当我包括它的打破。
  • 在我的控制台我看到错误,但不知道为什么它的发生
  • Uncaught ReferenceError: System is not defined
  • Uncaught TypeError: angular.module is not a function
  • RangeError: Maximum call stack size exceeded*
  • 你能告诉我如何解决它
  • 提供以下

http://jsfiddle.net/v3gdnLwu/茉莉花测试案例不在我的小提琴执行

我的代码
describe('myApp', function() { 
    var element, 
     name = 'Homer'; 
    beforeEach(function() { 
     module('myApp'); 
     element = angular.element('<my-drtv/>'); 
     inject(function ($rootScope, $compile) { 
      var scope = $rootScope.$new(); 
      scope.name = name; 
      $compile(element)(scope); 
      scope.$digest(); 
     }); 
    }); 
    it('says hello', function() { 
     expect(element.text()).toBe('Hello Homer'); 
    }); 
}); 

回答

0

您将需要包括系统的lib:

<script src="https://jspm.io/[email protected]"></script> 

当你这样做,你唯一剩下的问题将是在

var myApp = angular.module('myApp', []); 

angular.module线没有定义。您要么确保angular.module被正确定义,要么使用System.registerModule作为替代选项。