2017-06-07 5 views
1

私はChai.jsを使用しています。私はこれは私がCannot read property 'least' of undefinedChaijsアサーションでlengthOf.at.leastを使用

を言って、エラーメッセージを取得し合格しない以下のアサーション

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); 
}); 

を持っている。しかし、以下では正常に動作します。

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); 
}); 

どうして私は.at.least()を間違って使用していますか?

答えて

1

Chaiの旧バージョン(3.x)を使用しているようです。この問題を解決するには、最新バージョン(4.0.2)にアップグレードしてください。

npm i -D [email protected] 
関連する問題