【问题标题】:Chai expect that result equals one of three optionsChai 期望结果等于三个选项之一
【发布时间】:2020-01-16 04:49:36
【问题描述】:

我正在使用酶和 chai 来测试我的 React 应用程序。我想写一个测试结果是否等于三个可能选项之一的期望。 例如(sudo 代码):

expect(result).to.eq('red').or('green').or('yellow');

expect(result).to.beOneOf(['red','green','yellow']);

有什么办法可以做到吗?

【问题讨论】:

    标签: javascript reactjs enzyme chai


    【解决方案1】:

    我在 stackoverflow 上找到了这个解决方案 Chai expect to be one of array elements

    看起来我可以像这样改变我的期望” expect(['red', 'yellow', 'green']).to.include(result);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-28
      • 2014-09-08
      • 2014-09-01
      • 2022-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多