I have installed Mocha as well as Chai.
In my unit test:
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
works as expected, but should
is undefined.
Why?
You should call
chai.should()
at the begin of the file to useshould
style.It will extends each object with a
should
property to start your assertions chain.You can find more usage examples in chai documentation.