柴应该是未定义的
Chai should is undefined
我已经安装了 Mocha 和 Chai。
在我的单元测试中:
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
样式。
它将使用 should
属性 扩展每个对象以启动您的断言链。
您可以在 chai documentation 中找到更多使用示例。
我已经安装了 Mocha 和 Chai。
在我的单元测试中:
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
样式。
它将使用 should
属性 扩展每个对象以启动您的断言链。
您可以在 chai documentation 中找到更多使用示例。