return inputArr.filter(it => it.url.match(regex));根据Jest ,我应该能够用以下代码测试该函数抛出异常: ✓ it should return an empty array if there is an empty search term (1ms)
✕ it should throw<anonymous> (__tests__/filterByTerm.spec.js:35
TriedAddingDuplicateError)AssertionError: expected [Function] to throwTriedAddingDuplicateError' was thrown
Note1:如您所见,引发错误的方法是实例方法Note2:我确实尝试过使用另一种方法,即chai.expect(() => host1.add()).to.throw