Alon Alon - 1 year ago 127
Node.js Question

Chai should is undefined

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?

Answer Source

You should call chai.should() at the begin of the file to use should style.

It will extends each object with a should property to start your assertions chain.

You can find more usage examples in chai documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download