当 运行 在 Chutzpah 中而不是在浏览器中时,Jasmine 测试失败

Jasmine test fails when run in Chutzpah but not in browser

我有一个测试在浏览器中正常通过但在 Chutzpah 中失败。

这是失败的部分:

var nameLowerCase = person.PersonName.toLowerCase();
var searchLowerCase= search.toLowerCase();
return (nameLowerCase.includes(searchLowerCase));

放肆说:

Message: TypeError: undefined is not a constructor (evaluating 'nameLowerCase.includes(searchLowerCase)') ...

includes 函数似乎有问题,因为如果我删除它,它就会运行。

我可能会尝试用 Regex 或其他东西替换该功能,但要找到它非常痛苦。如果我遗漏了一些愚蠢的东西,我很乐意向我指出。

我仍然希望其他人回答这个问题,因为我想知道为什么 .includes 不起作用,但是使用 Regex 解决了我的问题:

var searchPattern= new RegExp(search, 'i');
return (person.PersonName.match(searchPattern));

PhantomJS使用的JS引擎暂不支持includes方法