我收到 ESLint 错误 Expect must have a corresponding matcher call - jest/valid-expect
在这个循环的第一行,我正在检查匹配的正则表达式( .toMatch
)。
const dateRegex = /^([1-9]|1[012])[- \\/.]([1-9]|[12][0-9]|3[01])[- \\/.](19|20)\d\d/
expect(getPerformancePerUserPerDay(input).forEach((item, index) => {
expect(item['Date']).toMatch(dateRegex)
}))
不确定我做错了什么,因为根据他们的 documentation 的用法似乎是正确的.这可能是一个错误吗?
最佳答案
第一个expect
没有断言任何东西,并且根据 jest/valid-expect
规则 Ensure expect() is called with a single argument and there is an actual expectation made.
这会触发错误。
改成:
getPerformancePerUserPerDay(input).forEach((item, index) => {
expect(item['Date']).toMatch(dateRegex)
})
关于javascript - Jest 和 ESLint : Expect must have a corresponding matcher call,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63191622/