空手道不包含任何

问题描述 投票:0回答:1

我试图断言数组不包含任何给定元素。 到目前为止我尝试过的:

* def foo = [1, 2, 3]
* match foo !contains [3, 4] # renders true, but i need it to be false --> !contains is not for this kind of assert
* match each foo !contains [3, 4] # error: datatypes don't match
* match foo !contains each [3, 4] # error: js syntax error
* match foo !contains any [3, 4] # error: !contains any not available

有没有办法在空手道中实现这种断言?

karate
1个回答
0
投票

是的,我自己对

!contains
感到困惑并且不推荐它。

我建议你做一个两步过滤。以此作为参考:

* def bad = [1, 2, 3]
* def actual = [4, 5, 6]
* def temp = actual.filter(x => bad.includes(x))
* match temp == []

另请参阅此答案以获取更多提示:https://stackoverflow.com/a/62567262/143475

© www.soinside.com 2019 - 2024. All rights reserved.