小编the*_*ict的帖子

Chai:如何使用'should'语法测试undefined

教程中使用chai测试angularjs应用程序时,我想使用"should"样式为未定义的值添加测试.这失败了:

it ('cannot play outside the board', function() {
  scope.play(10).should.be.undefined;
});
Run Code Online (Sandbox Code Playgroud)

错误"TypeError:无法读取属性'应该'未定义",但测试通过了"expect"样式:

it ('cannot play outside the board', function() {
  chai.expect(scope.play(10)).to.be.undefined;
});
Run Code Online (Sandbox Code Playgroud)

如何让它与"应该"一起工作?

javascript testing angularjs chai

92
推荐指数
6
解决办法
4万
查看次数

标签 统计

angularjs ×1

chai ×1

javascript ×1

testing ×1