使用should.js如何检查数组中是否存在字符串?

Kou*_*nha 2 javascript mocha.js should.js

想检查一个字符串是否存在于数组中someArray.should.contain('str'),但是我找不到对此进行的否定情况检查.

Tro*_*ott 7

使用.not应该工作:someArray.should.not.contain('str')

should.js自述中没有提到.contain().因此,如果简单插入.not不起作用,请使用.containEql().

  • `should.js` docs没有提到`contains`.也许有一些混合和匹配正在进行mocha和你真正想要的是`containsEql`或类似的东西? (5认同)