Search code examples
javascripttestingchai

Chai: Check if any array item is true using 'expect'


I need to check if [boolean,boolean,boolean] array contains only true using specifically expect from chai.
On stackoverflow I found solution with should keyword, but I am only allowed to use expect
As I found out from docs we can use expect(result).to.eql([true, true, true])
But what if we have array with length 100?


Solution

  • You can try something like this

    expect(result).to.eql(new Array(result.length).fill(true));