如何使用 'OR' 与摩卡 / 柴

How to use 'OR' with Mocha / Chai

我正在尝试测试文本是否包含 text1 或 text2。类似于:

expect(text).to.contain.text1 || expect(text).to.contain.text2.

有什么想法吗?

谢谢。

我想你可以使用 .oneOf(list).satisfy(function)

例如,

expect(text).to.be.oneOf(['hello', 'world']);

或者

expect(text).to.satisfy(function (t) {
  return t === 'hello' || t === 'world';
});