mardi 7 août 2018

Expect several but not all true

Suppose I have an array arr = [true, false, false, true, false]. I wish to assert that exactly two values are true in this array. Obviously, I could do something like this (with lodash):

Chai.expect(_.filter(arr, item => item == true)).to.have.length(2)

Is there a more Chai-y or Jest-y way to do this?

Aucun commentaire:

Enregistrer un commentaire