I have this array of strings:
[ "apple", "apple", "apple", "apple", "apple", "apple", ]
Is it possible to make an assertion with Chai that all elements in the array are equal to the certain value?
arrayFromApiResponse = [ "apple", "apple", "apple", "apple", "apple", "apple", ]
expectedFruit = "apple"
expect(arrayFromApiResponse).to ???
I need to test that each value in the arrayFromApiResponse
is "apple"
I found this https://github.com/chaijs/Chai-Things
Seems like with this library it can be accomplished like this:
expect(arrayFromApiResponse).should.all.be.a(expectedFruit)
But is it possible to achieve this without additional library? Maybe I can make some changes to arrayFromApiResponse
so it can be validated by Chai?
UPD: I have updated the question title to prevent marking my question as duplicate with reference to this type of questions: Check if all values of array are equal