柴应该是不确定的

我已经安装了摩卡和柴。

在我的unit testing中:

import {expect, should} from "chai"; describe("array", function () { it("has length of 1", function (done) { var arr = ["B"]; expect(arr).have.lengthOf(1); arr.should.have.lengthOf(1); }); }); 

expect按预期工作,但should是不确定的。

为什么?

你应该在文件的开头调用chai.should()来使用样式。

它将扩展每个对象与一个should属性来开始你的断言链。

您可以在chai文档中find更多使用示例。