为什么angularjs期望不工作?

时间:2014-07-28 06:33:34

标签: javascript angularjs unit-testing

我尝试用 angular.js 编写最简单的javascript单元测试,但它失败了,我不知道原因。

的test.html

<html>
  <head>
    <script src="angular-1.2.21/angular-scenario.js" ng-autotest></script>
    <script src="test1.js"></script>
  </head>
</html>

test1.js

describe('A suite', function() {
  it('should be true', function() {
    expect(5).toBe(5);
  });
});

我在服务器上部署两个文件(和libs)并调用html站点。测试运行但总是失败

expected undefined toBe 5 but was undefined

我错过了什么?

2 个答案:

答案 0 :(得分:1)

根据您提供的信息,我认为您尚未包含茉莉花文件

http://searls.github.io/jasmine-all/jasmine-all-min.js

在包含此代码后尝试了您的代码,它运行正常。

这是working fiddle

答案 1 :(得分:0)

我认为语法错误。尝试:

 expect(5).to.equal(5);

参考:http://chaijs.com/api/bdd/

相关问题