断言库
Chai 是一个非常灵活的断言库,它可以让你使用如下三种主要断言方式的任何一种:
assert:
这是来自老派测试驱动开发的经典的assert方式。比如:
assert.equal(variable, "value");
expect:
这种链式的断言方式在行为驱动开发中最为常见。比如:
expect(variable).to.equal("value");
should:
这也是在测试驱动开发中比较常用的方式之一。举例:
variable.should.equal("value");
PS:在本课程中我们将使用expect的断言方式。