testing - How to use 'OR' with Mocha / Chai -
i trying test if text has text1 or text2. like:
expect(text).to.contain.text1 || expect(text).to.contain.text2.
- there not
.or
any doesn't work because
.text()
doesn't allow me do:expect(text).to.contain.any.text(text1,text2)
no, doesn't work:
expect(text).to.contain.text1 || expect(text).to.contain.text2
.
any idea ?
thanks.
i think can use .oneof(list)
or .satisfy(function)
.
for example,
expect(text).to.be.oneof(['hello', 'world']);
or
expect(text).to.satisfy(function (t) { return t === 'hello' || t === 'world'; });
Comments
Post a Comment