BDD Syntax Error

I’m using Chai.js. I have the following assertion

it('Expects subjects in the response body', () => {
    expect(response.body).to.be.an('object').that.includes.key("subjects");
    expect(response.body.subjects).to.be.an('array').that.has.lengthOf.at.least(1);
});

This doesn’t pass I get an error message saying Cannot read property 'least' of undefined

But the following works fine.

it('Expects subjects in the response body', () => {
    expect(response.body).to.be.an('object').that.includes.key("subjects");
    expect(response.body.subjects).to.be.an('array').that.has.lengthOf(10);
});

So how am I using .at.least() incorrectly?

The method you want is isAtLeast()

http://chaijs.com/api/assert/#method_isatleast

That doesn’t work either. According to the docs (http://chaijs.com/api/bdd/#method_lengthof) it looks like it should work.

Sure enough, I was looking at the assert docs and not the expect/should. Sorry about that.

I copied your code into a local project and ran it using Mocha. It worked fine for me. What version of Chai are you using? Do you have other tests that run?

The problem ended up being the version of Chai.js I was using. Upgraded and it worked fine.