Expecting all array elements to match single value regardless of size using chai

Viewed 71

Considering an array [1, 1, 1] how can I validate that all elements matches 1 using chai.js? Is there something like expect(array).to.only.contain(1);?

1 Answers

One way I do it for elements in array is to go through each element and check that value:

array.forEach(el => expect(el).toBe(1));
Related