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

Time:07-28

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?

CodePudding user response:

You can try something like this

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