Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 柴应该是未定义的_Javascript_Node.js_Unit Testing_Mocha.js_Chai - Fatal编程技术网

Javascript 柴应该是未定义的

Javascript 柴应该是未定义的,javascript,node.js,unit-testing,mocha.js,chai,Javascript,Node.js,Unit Testing,Mocha.js,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);

我安装了摩卡和柴

在我的单元测试中:

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
属性扩展每个对象,以启动断言链

您可以在中找到更多用法示例